Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Menus not updated in dialog application

Posted on 1997-09-27
4
368 Views
Last Modified: 2013-11-19
I have a dialog app with a menu bar and a system menu.  My UPDATE_COMMAND_UI message handlers don't do anything.  Even the system menu items don't get updated (grayed out) like they do in a doc/view application.  Thanks for your help.
0
Comment
Question by:duncan2
4 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1307054
The problem I think your dialog is not sent WM_IDLEUPDATECOMMANDUI message. This message is MFC private message defined in afxpriv.h and is broadcast to all child window by main frame window using SendMessageToDescendnts. This is done from CWinApp::OnIdle function winch is called on idle time. I suppose you created your dialog with WM_POPUP style or it is modal so this message is not sent to it. I suggest you store pointer to your dialog somewhere, implement handler on WM_IDLEUPDATECOMMANDUI message in your dialog parent\owner class and explicity call pDialog->SendMessage(WM_IDLEUPDATECOMMANDUI)and pDialog->SendMessageToDescendants(WM_IDLEUPDATECOMMANDUI) the second function is required id your dialog class has any control bars.
0
 

Author Comment

by:duncan2
ID: 1307055
I need to clarify my problem.  You suggest that I may not be getting messages to my dialog, but my message handlers are in the app.  I started with a dialog app created with app-wizard.  If you make a new dialog app, add a menu resource and add it to the dialog with dialog editor, you will see that the system menu items that should be grayed out are not.  The class wizard will not let you add message handlers for the menus in the dialog class, but you can in the app.  So the handlers in my app simply call functions in the dialog class.  When you click on a menu item these functions are called and work fine.  I also have a timer in my dialog class and it receives WM_TIMER messages fine.  So even though the dialog is created in InitInstance with DoModal, the message loop seems to be running.  Only the UPDATE_COMMAND_UI messages don't seem to work.  And they only have to get to the app, not the dialog.  Do you have any other ideas? (I am using VC 4.0).
0
 
LVL 2

Expert Comment

by:SamratAshok
ID: 1307056
That is because MFC framework never supports the Update
Command UI on dialog boxes

COMMAND_UI functions are implemented by a kind of neat
trick in MFC in the CFrameWnd class, Since Dialog box
have no frame whatsoever, they have no Command UIs

When a user clicks on any menu, windows before
preparing the menu sends application

WM_INITMENUPOPUP message, One of the parameter word
identifies it as a system Menu

You can do either of the following two

Handle WM_INITMENUPOPUP and do all your updateUI logic
there

or copy and tweak the handler from MFC supplied source file
WINFRM.CPP (look for OnInitMenuPopup)

If you need further help you can reach me
at
cdjindia@hotmail.com
or
cdjindia@bestweb.net




In the MFC Source code, look for handlere
If you want to do that you have to provide
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1307057
Handle OnKickIdle to call AfxGetApp()->OnIdle(0);

The application is not getting any idle messages which does the updating of menus.


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question