Solved

Setting up a pop-up menu

Posted on 2000-03-13
6
308 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 30

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 30

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This story has been written with permission from the scammed victim, a valued client of mine – identity protected by request.
Read about the 3 stages of the buyer's journey: awareness, consideration, and decision.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
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.

760 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

21 Experts available now in Live!

Get 1:1 Help Now