?
Solved

Setting up a pop-up menu

Posted on 2000-03-13
6
Medium Priority
?
332 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
[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
  • 2
  • 2
6 Comments
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 200 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

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.
An overview of how to create reports in Adobe Analytics (formerly Omniture Site Catalyst) using pageNames, events, eVars and props. This video will show you how to install the Omniture Debugger tool so can see (and test) what is being passed int…
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.

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