Setting Menu Items from a view 
Author Message
 Setting Menu Items from a view

Does anyone know how to do this? I have an SDI app with a single menu and I
can do the following in the view:

 m_pMenu = GetParent()->GetMenu();
<snip>
  m_pMenu->EnableMenuItem(ID_FILE_SAVE, MF_ENABLED);

But in an MDI application with multiple menus, this doesn't work. I get a
Debug Assertion that it is not a valid menu.

Anyone know what is wrong?

Thanks,
Buck.



Sat, 26 Jul 2003 03:14:08 GMT  
 Setting Menu Items from a view
Buck,

In an MDI program the view has two parents.  You have to work back up the
chain.

Tom


Quote:
> Does anyone know how to do this? I have an SDI app with a single menu and
I
> can do the following in the view:

>  m_pMenu = GetParent()->GetMenu();
> <snip>
>   m_pMenu->EnableMenuItem(ID_FILE_SAVE, MF_ENABLED);

> But in an MDI application with multiple menus, this doesn't work. I get a
> Debug Assertion that it is not a valid menu.

> Anyone know what is wrong?

> Thanks,
> Buck.



Sat, 26 Jul 2003 03:08:25 GMT  
 Setting Menu Items from a view
In MDI (and SDI) you can call GetTopLevelFrame().

--
Ajay Kalra [MVP - VC++]

Note: Please post all replies to newsgroup only.


Quote:
> Does anyone know how to do this? I have an SDI app with a single menu and
I
> can do the following in the view:

>  m_pMenu = GetParent()->GetMenu();
> <snip>
>   m_pMenu->EnableMenuItem(ID_FILE_SAVE, MF_ENABLED);

> But in an MDI application with multiple menus, this doesn't work. I get a
> Debug Assertion that it is not a valid menu.

> Anyone know what is wrong?

> Thanks,
> Buck.



Sat, 26 Jul 2003 03:41:45 GMT  
 Setting Menu Items from a view
I don't get an Assertion, however the EnableMenuItem is not doing anything
to my menu. Any other suggestions.

Thanks for your help.
Buck.


Quote:
> In MDI (and SDI) you can call GetTopLevelFrame().

> --
> Ajay Kalra [MVP - VC++]

> Note: Please post all replies to newsgroup only.



> > Does anyone know how to do this? I have an SDI app with a single menu
and
> I
> > can do the following in the view:

> >  m_pMenu = GetParent()->GetMenu();
> > <snip>
> >   m_pMenu->EnableMenuItem(ID_FILE_SAVE, MF_ENABLED);

> > But in an MDI application with multiple menus, this doesn't work. I get
a
> > Debug Assertion that it is not a valid menu.

> > Anyone know what is wrong?

> > Thanks,
> > Buck.



Sat, 26 Jul 2003 04:18:01 GMT  
 Setting Menu Items from a view
In MFC, you do not use EnableMenuItem to any menu item which belongs to a
mainframe window. You should write ON_UPDATE_COMMAND_UI handlers to
enable/disable a menu item. This would be called each time a menu is about
to display and overrides the state set previously.

--
Ajay Kalra [MVP - VC++]

Note: Please post all replies to newsgroup only.


Quote:
> I don't get an Assertion, however the EnableMenuItem is not doing anything
> to my menu. Any other suggestions.

> Thanks for your help.
> Buck.



> > In MDI (and SDI) you can call GetTopLevelFrame().

> > --
> > Ajay Kalra [MVP - VC++]

> > Note: Please post all replies to newsgroup only.



> > > Does anyone know how to do this? I have an SDI app with a single menu
> and
> > I
> > > can do the following in the view:

> > >  m_pMenu = GetParent()->GetMenu();
> > > <snip>
> > >   m_pMenu->EnableMenuItem(ID_FILE_SAVE, MF_ENABLED);

> > > But in an MDI application with multiple menus, this doesn't work. I
get
> a
> > > Debug Assertion that it is not a valid menu.

> > > Anyone know what is wrong?

> > > Thanks,
> > > Buck.



Sat, 26 Jul 2003 04:42:24 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Setting Menu Items from a view

2. Set menu item invisible

3. Setting bitmaps to menu items

4. Q: Set Check Mark in Menu Item In Based Dialog Application

5. Setting bitmaps to menu items

6. Set checked stated in menu item

7. control menu item in doc/view

8. problem with view list under window menu item

9. How to bring an item into view in CListBox with LBS_MULTIPLESEL set

10. Trying to disable Menu Item and ToolbarCtrl item..

11. help working with context menus and adding menu items dynamically

12. Suspend menu item in the Start Menu

 

 
Powered by phpBB® Forum Software