Click to See Complete Forum and Search --> : 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.........
Dhwanit
July 6th, 1999, 09:40 AM
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
dhwanit@logicad.8m.com
Roger Allen
July 6th, 1999, 10:05 AM
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
blarivie
July 6th, 1999, 10:24 AM
I would recommand you to handle WM_CONTEXTMENU instead of WM_RBUTTONDOWN.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.