?
Solved

Simple TrackPopupMenu

Posted on 1998-05-13
4
Medium Priority
?
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 90 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

777 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