Solved

Setting up a pop-up menu

Posted on 2000-03-13
6
312 Views
Last Modified: 2013-12-03
Hi,

At the moment, I have created my pop-up menu like so:

BOOL bSuccess;

HMENU hMenu = CreatePopupMenu();

bSuccess = AppendMenu( hMenu, MF_STRING, 1, "&Colours" );

bSuccess = AppendMenu( hMenu, MF_STRING, 2, "&Highlight" );

UINT iMenu = TrackPopupMenu( hMenu, TPM_RIGHTALIGN | TPM_RETURNCMD | TPM_LEFTBUTTON, point.x, point.y, 0, m_xList.GetParent(), NULL );

I would prefer to define a menu resource instead, but I am not sure how to reference that instead. I have looked at the method LoadMenu() but I can't get hold of the hInstance to the application.

Are there any other ways to do this..

TIA

Emma
0
Comment
Question by:middlel
  • 2
  • 2
  • 2
6 Comments
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 50 total points
ID: 2612186
if you have a WinMain it is the first parameter that is passed. Most people save it away into a global so that it can be used later on
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2612192
Hi middled,

to use LoadMenu you need the instance handle of the module from which you want to load the menu. The instance handle is passed to the WinMain function of your application.

hint: to create a popup menu from resource you'll have to create an empty (dummy-)menu including your popup menu as 'child' menu and load it like this:

HMENU hMenu = LoadMenu( hInstance, ID_MY_DUMMY_MENU );
HMENU hPopupMenu = GetSubMenu( hMenu, 0 );
TrackPopupMenu( hPopupMenu, ... );

hope that helps,

ZOPPO
0
 

Author Comment

by:middlel
ID: 2612269
hmm.. that is what I thought.. Unfortunately my application is an ATL dll and the only WinMain() I have is in in the little Win32 exe that launches the dll. I can't rely on that hInstance because my dll may have a VB container next time and then I would not be able to get the hInstance.

regards,

Emma
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 31

Expert Comment

by:Zoppo
ID: 2612371
If it's an dll there should be a DllMain which get's the instance handle for the dll passed as argument...
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2612433
if it is an ATL DLL then you can use
_Module.GetResourceInstance()
0
 

Author Comment

by:middlel
ID: 2612838
thanks a lot...

Emma
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

For many of us, the  holiday season kindles the natural urge to give back to our friends, family members and communities. While it's easy for friends to notice the impact of such deeds, understanding the contributions of businesses and enterprises i…
Learn about the eCommerce marketing trends for the year ahead.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now