Question : Delphi Pagecontrol - each Tabsheet has its own popup menu

I have a pagecontrol and would like to have a popup menu "close all other tabs". The tabsheets are create dynamically during runtime.
Wolrks fine, but I have to determine what tab has the right click....?
Or is there any chance to activate this tab before processing the right click.

thanx for your help

Answer : Delphi Pagecontrol - each Tabsheet has its own popup menu

Hi sb67pro. Use TabRect function like this:

procedure TForm1.PopupMenu1Popup(Sender: TObject);
var
  CurPos: TPoint;
  R: TRect;
  i: Integer;
begin
  if GetCursorPos(CurPos) then
  begin
    CurPos:= PageControl1.ScreenToClient(CurPos);
    for i:= 0 to PageControl1.PageCount-1 do
    begin
      R:= PageControl1.TabRect(i);
      if (CurPos.X >= R.Left) and (CurPos.X <= R.Right) and (CurPos.Y >= R.Top) and (CurPos.Y <= R.Bottom) then
        Caption:= 'Clicked on tab of page ' + IntToStr(i);
    end;
  end;
end;
Random Solutions  
 
programming4us programming4us