?
Solved

Setting up a pop-up menu

Posted on 2000-03-13
6
Medium Priority
?
337 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

Reclaim your office - Try the MB 660 headset now!

High level of background noise often makes it difficult for employees to concentrate fully on their jobs – or to communicate clearly on calls. The MB 660 headset helps you create a disruption free workspace.  

Question has a verified solution.

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

A great marketing strategy is diverse.  Read about the not so popular, yet effective, marketing tactics you can start using today!
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:
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…

650 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