Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to create a popup menu for a tab of a TPageControl Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
01-Nov-02
Category
VCL-General
Language
Delphi 2.x
Views
62
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC