Solved

Setting up a pop-up menu

Posted on 2000-03-13
6
326 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 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Read about why website design really matters in today's demanding market.
In this blog, I will share you some basic tips for content marketing and to rank your website on Google.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

690 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