whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1547)

Database (90)
Files (137)
Forms (107)
Graphic (115)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

43 Visitors Online


 
...rearrange the tabs in a TPageControl using drag 'n drop ?
Autor: unknown
[ Print tip ]  

Tip Rating (15):  
     




// In the PageControl's OnMouseDown event handler:

procedure TForm1.PageControl1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  
PageControl1.BeginDrag(False);
end;


// In the PageControl's OnDragDrop event handler:

procedure TForm1.PageControl1DragDrop(Sender, Source: TObject; X, Y: Integer);
const
  
TCM_GETITEMRECT = $130A;
var
  
i: Integer;
  r: TRect;
begin
  if not 
(Sender is TPageControl) then Exit;
  with PageControl1 do
  begin
    for 
i := 0 to PageCount - 1 do
    begin
      
Perform(TCM_GETITEMRECT, i, lParam(@r));
      if PtInRect(r, Point(X, Y)) then
      begin
        if 
i <> ActivePage.PageIndex then
          
ActivePage.PageIndex := i;
        Exit;
      end;
    end;
  end;
end;

// In the PageControl's OnDragOver event handler:

procedure TForm1.PageControl1DragOver(Sender, Source: TObject; X,
  Y: Integer; State: TDragState; var Accept: Boolean);
begin
  if 
Sender is TPageControl then
    
Accept := True;
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners