Jump to content


bion's Content

There have been 2 items by bion (Search limited from 25-April 23)


By content type

See this member's

Sort by                Order  

#17521 PageControl with tab-moving

Posted by bion on 29 January 2014 - 03:14 PM in Next Collection

Hello Boki,

//Using D2007 and NextSuite 5 1.2014
//Can't find option tab-moving in NxPageControl
//Based on above Drag & Drop suggestion, here is a method for tab-moving with visual feedback of the tab...
//-----------------
//2 global var needed
//first tab is on the form, new tabs are created at runtime (based on count of files...)
var
iLDownMB: integer;
iLDraggingMB : integer;
//-----------------
procedure FocusFirstEntryControl(ContainerToFocus : TWinControl) ;
var
i : integer;
begin
for i := 0 to ContainerToFocus.ControlCount - 1 do
begin
if (ContainerToFocus.Controls[i] is TWinControl) then
begin
TWinControl(ContainerToFocus.Controls[i]).SetFocus;
Break;
end;
end;
end;
//-----------------
procedure TfrmMain.NxPageControl1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
iLDownMB:= 0;
iLDraggingMB := 1;
if (Button = mbLeft) then
begin
iLDownMB:= 1;
iLDraggingMB := 0;
end
else
begin
if (Button = mbRight) then
begin
iLDownMB:= 0;
iLDraggingMB := 1;
end;
end;
end;
//-----------------
procedure TfrmMain.NxPageControl1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (Button = mbLeft) then
begin
iLDownMB:= 0;
iLDraggingMB := 1;
case NxPageControl1.ActivePageIndex of
0 :
begin
// custom code for the first tab ...
end;
else
begin
//focus on the other tabs created at runtime
FocusFirstEntryControl(NxPageControl1.ActivePage);
end;
end;
end;
if (Button = mbRight) then
begin
iLDownMB:= 0;
iLDraggingMB := 1;
// a popup comes here for example
end;
end;
//-----------------
procedure TfrmMain.NxPageControl1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if (NxPageControl1.PageCount > 1) then // do nothing for the first tab = no moving allowed
begin
if (iLDownMB = 1) then
begin
if (iLDraggingMB = 0) then
begin
iLDraggingMB := 1;
case NxPageControl1.ActivePageIndex of
0 :
begin
//
end;
else
begin
if NxPageControl1.GetTabAtPos(X, Y) <> nil then // <---- added by Boki
begin
NxPageControl1.BeginDrag(false, 5);
end;
end;
end;
end;
end;
end;
//-----------------
procedure TfrmMain.NxPageControl1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
var
ts: TnxTabSheet;
begin
//Source = NxPageControl1 --> several PageControls on the form
if (Source = NxPageControl1) and (Sender = Source) then
begin
case TNxPageControl(Sender).ActivePageIndex of
0 :
begin
//nothing allowed for the first tab
Accept := False;
end;
else
begin
Accept := True;
ts := TNxPageControl(Sender).GetTabAtPos(X, Y);
if Assigned(ts) then // <--- added by Boki
if (ts.PageIndex > 0) and
(ts.PageIndex < TNxPageControl(Sender).PageCount) and
(ts.PageIndex <> TNxPageControl(Sender).ActivePage.PageIndex) then
begin
TNxPageControl(Sender).ActivePage.PageIndex := ts.PageIndex;
end;
end;
end;
end
else
begin
//another drag & drop from another component
if (Source = NextGrid1) then
begin
//
end;
end;
end;
//-----------------
procedure TfrmMain.NxPageControl1lDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (Source = NxPageControl1) and (Sender = Source) then
begin
case TNxPageControl(Sender).ActivePageIndex of
0 :
begin
//custom method for the first tab
end;
else
begin
FocusFirstEntryControl(NxPageControl1.ActivePage);
end;
end;
end
else
begin
//another drag & drop from another component
if (Source = NextGridMB) then
begin
//
end;
end;
end;
//-----------------

Regards,

Jan Maryssael



#17470 TNxPageControl: Close button on every Tab

Posted by bion on 29 November 2013 - 05:32 PM in Next Collection

Hello Boki,

How can I set a close button on every Tab of the NxPageControl (either at designtime or at runtime)?
(like the close buttons on the Tabs in Firefox for ex.)

Regards,
Jan