Solved

Simple TrackPopupMenu

Posted on 1998-05-13
4
308 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 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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 accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

728 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