menu [modified]
-
I have to add a menu item on right clicking selected text, invoke my command handler and get the selected text, from any text document 1. How to add menu item to the existing windows generated menu 2. How to get the selected text to the menu handler program Thanks Anil -- modified at 4:31 Tuesday 13th February, 2007
-
I have to add a menu item on right clicking selected text, invoke my command handler and get the selected text, from any text document 1. How to add menu item to the existing windows generated menu 2. How to get the selected text to the menu handler program Thanks Anil -- modified at 4:31 Tuesday 13th February, 2007
then, what's your question ? where's your problem ? what have you tried already ? where are you blocked ?
[VisualCalc][Flags Beginner's Guide] | [Forums Guidelines][My Best Advice]
-
then, what's your question ? where's your problem ? what have you tried already ? where are you blocked ?
[VisualCalc][Flags Beginner's Guide] | [Forums Guidelines][My Best Advice]
I have to add a menu item on right clicking selected text, invoke my command handler and get the selected text, from any text document 1. How to add menu item to the existing windows generated menu 2. How to get the selected text to the menu handler program
-
I have to add a menu item on right clicking selected text, invoke my command handler and get the selected text, from any text document 1. How to add menu item to the existing windows generated menu 2. How to get the selected text to the menu handler program
Use
WM_CONTEXTMENU
. The handler is calledOnContextMenu
). There you can use code like this://Start CSM
CMenu menu; menu.LoadMenu( IDR_CONTEXT_MENUS);
CMenu* pContextMenu = menu.GetSubMenu( 1); // context menu ViewCSM
CMenu* pWorkMenu = menu.GetSubMenu( 2); // context menu WorkCSM
if( pWorkMenu) {
MergeMenu( pContextMenu, pWorkMenu);
}
pContextMenu->TrackPopupMenu( TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);Instead of
MergeMenu
, you might as well add an item. For this to work, I have made a menu-resource where I place all my context menus as submenus. The code that handles the selected menu item does so using the menu item IDs I gave in the resource. The last paramter toTrackPopupMenu()
defines theclass that is the parent for the menus and gets the command messages.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.
-
Use
WM_CONTEXTMENU
. The handler is calledOnContextMenu
). There you can use code like this://Start CSM
CMenu menu; menu.LoadMenu( IDR_CONTEXT_MENUS);
CMenu* pContextMenu = menu.GetSubMenu( 1); // context menu ViewCSM
CMenu* pWorkMenu = menu.GetSubMenu( 2); // context menu WorkCSM
if( pWorkMenu) {
MergeMenu( pContextMenu, pWorkMenu);
}
pContextMenu->TrackPopupMenu( TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);Instead of
MergeMenu
, you might as well add an item. For this to work, I have made a menu-resource where I place all my context menus as submenus. The code that handles the selected menu item does so using the menu item IDs I gave in the resource. The last paramter toTrackPopupMenu()
defines theclass that is the parent for the menus and gets the command messages.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.
Can we add the menu item via registry as we add menu items, on right clicking files,folder etc
-
Can we add the menu item via registry as we add menu items, on right clicking files,folder etc
i think you're wanting this[^]
[VisualCalc][Flags Beginner's Guide] | [Forums Guidelines][My Best Advice]
-
Can we add the menu item via registry as we add menu items, on right clicking files,folder etc
What do you mean? Where you get your menu text and menu ID does not matter:
CMenu
allows you to add arbitrary text and numbers. You may as well load it from registry entries. If you want to change a menu from a menu bar, you would need to handleWM_INITMENU
or overrideCWnd::OnInitMenu
. There you can modify the menu - to the point of assembling a completely different menu.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.