View Single Post
Join Date: Mar 2006
Posts: 14
Reputation: vickzbrit is an unknown quantity at this point 
Solved Threads: 0
vickzbrit vickzbrit is offline Offline
Newbie Poster

Re: Disable/Enable Menu Items and Sub Items

 
0
  #3
Nov 22nd, 2008
Originally Posted by koushal.vv View Post
I have faced this problem before....
just go to the menu right click on it ,
say add event handler, Add the ONUpdate
event handler. U will have to enable
Every menu, Sub Menu OnUpdate event handler.
Then its quite simple use the pCMdUI->enable()
method to enable / Disable menu depending upon the condition.
The other method is to create a pop up menu , where the
enabling and disabling of menus will be simpler.
Hope i have solved u r problem , if not reply back here
I think I have already done that part and still it would not work. Below is the code to ensure that we are talking about the same part.

  1. void CDeptView::OnSortManager()
  2. {
  3. Selected = "MANAGER"; // Selected is a variable
  4. // Pulling out data from the access table
  5. m_pSet->m_strSort="[Managers].[ManagerName]";
  6. m_pSet->Requery();
  7. m_pSet->MoveFirst();
  8. UpdateData(FALSE);
  9. }

  1. void CDeptView::OnUpdateSortManager(CCmdUI *pCmdUI)
  2. {
  3. // Setting a check to the menu item but it doesn't work now as
  4. it has sub menu items
  5. pCmdUI->SetCheck(( m_SelectedSort == "MANAGER")? 1 : 0 );
  6. // Bellow is the condition when I want the menu item and its
  7. sub item to be disabled.
  8. if(Selected == "drum" || Selected == "guitar" || Selected == "mic" || Selected == "computer" || Selected == "car" || Selected == "hockey" || Selected == "laptop" || Selected == "watch" )
  9. {
  10. pCmdUI->Enable(Sort == 1);
  11. }
  12. }

This is how I have my code and it doesn't work. In a menu bar I have Sort. Under Sort I have Manager. Under Manager I have 2 other menu items. Before having thoes 2 menu items, Manager worked with check mark as well as disabling. After having sub menu items it wont. Can anyone help me out with it.

Vicky
Reply With Quote