Author: Tomas Rutkauskas How to create a popup menu for a tab of a TPageControl Answer: 1 { ... } 2 uses 3 commctrl; 4 5 procedure TabMenuPopup(APageControl: TPageControl; X, Y: Integer; ); 6 var 7 hi: TTCHitTestInfo; 8 TabIndex: Integer; 9 p: TPoint; 10 begin 11 hi.pt.x := X; 12 hi.pt.y := Y; 13 hi.flags := 0; 14 TabIndex := APageControl.Perform(TCM_HITTEST, 0, longint(@hi)); 15 p.x := APageControl.Left + X; 16 p.y := APageControl.Top + y; 17 p := ClientToScreen(p); 18 {Allows use of different menus for each tab...} 19 case TabIndex of 20 0: {on the first tab...} 21 PopupMenu1.Popup(P.x, P.Y); 22 1: {on the second tab...} 23 PopupMenu2.Popup(P.x, P.Y); 24 end; 25 end; 26 end; 27 28 procedure TForm1.PageControl1MouseDown(Sender: TObject; 29 Button: TMouseButton; Shift: TShiftState; X, Y: Integer); 30 begin 31 if Button = mbRight then 32 begin 33 TabMenuPopup(PageControl1, X, Y); 34 end; 35 end;