Originally Posted by
koushal.vv
So what u r saying is
first the menu looked like this
SORT
|
MANAGER
Here Enabling and Disabling of manager Menu can be done,
now u have updated the manager menu like this :
SORT
|
MANAGER --- SUBMENU1
--- SUBMENU2
here u will not be able to disable the MANAGER menu as u will not be able to add an Valid event for it. Since u have added the SUNBMENU's now , u can again create the ONUPDATE event for them, then try to put the same logic into them and disable both of the sub menus. Here in the MANAGER menu when u click on it no event will be generated. MANAGER menu will be now same as SORT menu where valid event handler's cant be added. hope this helps u .
Yes, that is correct. But I can disable Sort. The code for that is given below.
void CDept::DisableSort(void)
{
CWnd* pParent = GetParent(); // This is a point to the window
// This is a pointer to the menu on that window
CMenu* pMenu = pParent->GetMenu();
if (m_pSet->GetRecordCount()==0) {
MessageBox("Error", MB_ICONSTOP);
// This disables the menu item in the 6th position which
is Sort
pMenu->EnableMenuItem(5 , MF_BYPOSITION | MF_GRAYED );
}
m_pSet->MoveFirst();
pParent->DrawMenuBar(); // To redraw the menu
OnSortEmployee(); // To reset the sort back to the “default condition”
}
But the question is how am i suppose to gray out or disable the menu item in the sort. Check out the code bellow
//(5) is the position of the sort, (MF_BYPOSITION ) is saying that it can be done by position of the Sort which is 5, (MF_GRAYED) means it grays out the SORT.
pMenu->EnableMenuItem(5 , MF_BYPOSITION | MF_GRAYED );
Now the problem is I can not do the same thing for the sub menu of Sort. But I don't know the position for that. If there is another piece of code to get the job done, then I have no idea about it. This is where I am stuck.
Vicky
Last edited by vickzbrit; Nov 22nd, 2008 at 2:25 pm.