I'm trying to use TrackPopupMenuEx to show a popup menu, the menu is created
dynamically, and the WindowHandle has been set.
If I use the PopupMenu.Popup() procedure it shows ok, but if I click outside
of the menu it does not disappear, so that is why I need the
TrackPopupMenuEx function.
But if I try this it kills the Application, in this case its MS Outlook that
is the ForeGround Window, I am accessing this from within an Exchange
Extension.
If I use a HMENU and create it using CreatePopupMenu then populkate the
popup it works fine, but creating the popup menu from TPopupMenu doesn't
seem to work?
I want to use the TPopupMenu because of the extra features it has, bitmaps
etc.
I can get the TrackPopupMenuEx function to work, but only if I don't include
the Images line, which then pops up the window that is the same as using the
HMENU CreatePopupMenu method.
Any ideas on what's wrong, below is a code snippet of what I am using:
MyWindow := GetForegroundWindow;
MyMessage.message := WM_COMMAND;
PeekMessage(MyMessage, MyWindow, 0, 0, PM_NoRemove);
MyPoint := MyMessage.pt;
if cmdid = cmdidMenu then
begin
PopupMenu := TPopupMenu.Create(MyTest);
PopupMenu.WindowHandle := MyWindow;
PopupMenu.Images := MyTest.ilImages;
PopulatePopup(PopupMenu, 6, EnvTemplates, EnvNetTemplates,
False, True, MenuItemClick);
if TrackPopupMenuEx(PopupMenu.Handle, TPM_LEFTALIGN +
TPM_LEFTBUTTON, MyPoint.x,
MyPoint.y, MyWindow, nil) then
Do stuff here...
Regards
Jason Coley
Manawatu Software Solutions
email: [EMAIL PROTECTED]
web: http://www.software-solutions.co.nz
_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi