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

Tips (1541)

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

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

46 Visitors Online


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

Tip Rating (22):  
     




// 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