Simple (I hope) question

I now know why I love working in C++ Builder.  I'm doing (customer requirements) a project where the PC side is in Visual C++ 6.0, and am pulling hairs.  I'm trying to do some simple things, and cannot begin to find where to do them.

The one I am trying now is to grey a menu line.  I design it grayed, and it shows up not grayed.  I use this code trying to change it's status...

     CMenu* pSysMenu = GetSystemMenu(FALSE);

and it remains not grayed.  I've tried several flag combination (MF_BYCOMMAND or MF_BYPOSITION), they fail, but other functions like AppendMenu are working, so the handle retrieved is correct.

I said this is easy, but it's pretty urgent, so I'm paying out a lot.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In SDI and MDI application you cannot set menu and toolbar items state directly. Instead of this you need to overwrite UPDATE_COMMAND_UI message handler. To do this, right-click on one of application classes (for exmple, CMainFrame), seleca "Add Windows Message Handler", select ID_BURN_FILEBURN and double-click on UPDATE_COMMAND_UI. In the function write:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
This handle is called when parent menu item is opened (WM_INITMENUPOPUP) or in idle time for toolbar buttons. Any changes done by using EnableMenuItem is overwritten by UPDATE_COMMAND_UI handler.
sburckAuthor Commented:
OK - that did it.  I'm going to ask why, though, there is a distinction, even though I'm hoping not to need it again for a long time.  The points are yours, but if you have a few seconds to explain why this is, I'd appreciate it.
In SDI/MDI application program doesn't update menu and toolbar state directly. Instead of this you write condition which defines item state (enabled/disabled, checked/unchecked...). For example, if you want to have Save command enabled only when information is changed, you write:

void CMainFrame::OnUpdateFileSave(CCmdUI* pCmdUI)

instead of enabling menu item every tyme user types a symbol. Program changes it's state and MFC framework applies conditions when necessary.
Menu items are updated when parent menu is poped-up. Toolbar buttons are updated in idle time.
When some program event occures, you don't think "How to change all menu items according to the new state". You just keep the new state changing some flag.
sburckAuthor Commented:
Thanks for the explanation.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.