|
-
July 6th, 1999, 09:30 AM
#1
Popup Menu
Hi all
In Dialog Box or View whenever I press Right Button of the Mouse, how to flash a Popup Menu?
Thanks in advance.........
-
July 6th, 1999, 09:40 AM
#2
Re: Popup Menu
Trap the WM_RBUTTONDOWN window message. When that is done, in the function, create the CMenu and flash it. This is also known as shortcut menus.
Cheers!
DP
[email protected]
-
July 6th, 1999, 10:05 AM
#3
Re: Popup Menu
Create a menu resource called for example IDM_MYMENU, with the required menu options in it.
In the OnRButtonDown(), use the following code :
OnRBUttonDown()
{
CMenu my_menu ;
CMenu *sub_menu ;
CPoint point ; // mouse position
CRect area ;
this->GetWindowRect(&area) ; // valid area to dismiss menu
my_menu.LoadMenu(IDM_MYMENU) ; // loads the menu resource
sub_menu = my_menu.GetSubMenu(0) ; // needed to get he acyual items you want to display
GetCursorPos(&point) ;
sub_enu->TrackPopupMenu(TPM_CENTERALIGN | TPM_LEFTBUTTON, point.x, point.y, this, area) ;
}
Then you just need to map the relevant ON_COMMAND codes for your menu items...
I have done most of this from memory, so there may be an odd bug-ette in there....
HTH
Roger Allen
Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
Please remember to rate useful answers. It lets us know when a question has been answered.
-
July 6th, 1999, 10:24 AM
#4
Re: Popup Menu
I would recommand you to handle WM_CONTEXTMENU instead of WM_RBUTTONDOWN.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|