|
-
April 30th, 2004, 06:33 AM
#1
To get all the items in the menu and know if the menu item is disabled or enabled
Hi,
In a tree control, I would like to find out programatically if context menu would be displayed on right clicking a particular node. If any menu is displayed, then I should be able to get all the items in the menu and know if the menu item is disabled or enabled.
How can this be done?
regards,
Kalpu
-
April 30th, 2004, 09:23 AM
#2
hi,
yes, you can display a context menu by right click over the tree
control and then you can interate trough all the menu items and see which one is enabled or vice versa
in MFC you only need an object from type CMenu
you need:
GetMenuItemCount
GetMenuString
GetMenuState
you can open context menu on right mouse click over the tree like this (you need to have one menu already and name it IDR_MENU1 for example):
Code:
void CMyProjectDlg::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
CMenu menu;
if (!menu.LoadMenu(IDR_MENU1))
return;
CMenu* pSubMenu = menu.GetSubMenu(0);
if (!pSubMenu)
return;
CPoint mouse;
GetCursorPos(&mouse);
::SetForegroundWindow(this->m_hWnd);
::TrackPopupMenu(pSubMenu->m_hMenu, 0, mouse.x, mouse.y, 0, this->m_hWnd, NULL);
*pResult = 0;
}
hope this helps,
regards,
typecast
-
May 2nd, 2004, 12:31 PM
#3
Originally posted by typecast
yes, you can display a context menu by right click over the tree
control
Originally posted by kalpu
I would like to find out programatically if context menu would be displayed on right clicking a particular node. If any menu is displayed, then I should be able to ...
Originally posted by typecast
yes, you can display a context menu by right click over the tree
control
I think question was not about how to display menu but detecting if menu is to be displayed.
Kalpu, handle WM_INITMENUPOPUP message. See MSDN for details.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
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
|