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 make a popup menu appear at a certain position over the Windows Taskbar 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
03-Oct-02
Category
System
Language
Delphi 2.x
Views
88
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius 

I create my popup menu items dynamically (not ownerdrawn). To place the popup menu 
at the right position (above a component), I need to determine (read) the menu item 
height. How would I do this?

Answer:

It's quite shocking but the API offers no way to do this. The API method to get a 
menu to pop up in a given area is TrackPopupMenuEx. Unfortunately it is not easily 
applicable with a Delphi popup menu, since you cannot get the handle of the tool 
window the Menus unit uses to process the menu messages. So you would have to 
duplicate that windows message processing in another window you can get at, e.g. 
the form.

Make a popup menu pop up over the taskbar, bottom aligned to taskbar top:

1   procedure TForm1.Button1Click(Sender: TObject);
2   var
3     pm: TTPMParams;
4     DisplayPoint: TPoint;
5     r: TRect;
6   begin
7     SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0);
8     r.top := r.bottom + 1;
9     r.bottom := screen.height;
10    DisplayPoint := Point(699, r.top);
11    with pm, pm.rcexclude do
12    begin
13      Top := r.top;
14      Bottom := r.bottom;
15      Left := 0;
16      Right := screen.width;
17      cbSize := SizeOf(pm);
18    end;
19    TrackPopupMenuEx(PopupMenu1.Handle, TPM_VERTICAL or TPM_HORIZONTAL,
20      DisplayPoint.x, DisplayPoint.y, Handle, @pm);
21  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