Solved

Simple TrackPopupMenu

Posted on 1998-05-13
4
306 Views
Last Modified: 2013-12-03
I have this problem : When I call TrackPopupMenu , the popup menu is displayed , but it is not "shown" , I mean it shows only something like a simple vertical Bar . I can see that it captures the mouse messages , and when I select a popup menu ( inside the menu ) , it is activated correctly

Any help ? Thanks
0
Comment
Question by:WxW
  • 2
4 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1401505
Are there items in the menu?  It might be that it is displaying a menu with zero menu items.  Can you use GetMenuItemCount() to confirm that there are menu items?
0
 
LVL 6

Author Comment

by:WxW
ID: 1401506
Sure there are items , because this menu is taken by LoadMenu from a resource , and anyway , I CAN select and execute the menu commands , I just can't see them ! Think that there is a bar , about the half size of a scroll bar .
0
 
LVL 11

Accepted Solution

by:
alexo earned 30 total points
ID: 1401507
The menu has to be a popup submenu.

Given that:

    hwnd = the window handle
    hinst = the application instance
    hmenu = LoadMenu(hinst, MAKEINTRESOURCE(IDR_MENU)) or similar

Here's a code that works for me:

    GetCursorPos(&pos);
    SetForegroundWindow(hwnd);
    TrackPopupMenuEx(GetSubMenu(hmenu), TPM_HORIZONTAL, pos.x, pos.y, hwnd, NULL);
    PostMessage(hwnd, WM_NULL, 0, 0);

And the menu is:

    IDR_MENU MENU DISCARDABLE
    BEGIN
        POPUP "Menu"
        BEGIN
            MENUITEM "About",                       IDM_ABOUT
            MENUITEM SEPARATOR
            MENUITEM "Exit",                        IDM_EXIT
        END
    END

0
 
LVL 6

Author Comment

by:WxW
ID: 1401508
Yes thanks alexo , that was the problem . I was trying not to use a submenu , but rather a menu from a resource .
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question