Click to See Complete Forum and Search --> : Disable Menu-Items


Martin Thoma
April 12th, 1999, 03:47 AM
Disable Menu-Items

Hi !

I'm using a CMDIFrameWnd as main-window. My problem: I don't want to use the ON_UPDATE_COMMAND_UI-stuff, to do the enabling and disabling of the items of the menu in the framewindow. I want something like:

Somewhere in the code, I want to say:

menu->EnableMenuItem(command_id, MF_DISABLED);

to disable an item.
The problem is, that MFC overrides this states set somewhere in the programm. I tried to override OnInitMenu and OnInitPopupmenu, but it doesn't help.

It's very important, that we can use this sort of command-handling. There is no other (easy) way to implement our programm. Please help !

Regards

Martin

Dave Lorde
April 12th, 1999, 04:04 AM
MFC user-interface update command message handling is designed to use the ON_UPDATE_COMMAND_UI handlers. They are called during idle processing and WM_INITMENUPOPUP message handling. You will find it an uphill struggle to implement an alternative.

It is possible to disable the default disabling of user-interface objects using CFrameWnd::m_bAutoMenuEnable flag, but this doesn't sound like what you want.

As is usually the case with MFC, you need a very strong reason to go against its design intent, and a very detailed knowledge of its internals to make the alternative work.

Why don't you want to use ON_UPDATE_COMMAND_UI handlers?

Dave