Click here to Skip to main content
15,912,400 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Load application as view Pin
Geert van Horrik22-Aug-05 4:47
Geert van Horrik22-Aug-05 4:47 
Generalsubclass all Pin
johny_d22-Aug-05 2:33
johny_d22-Aug-05 2:33 
GeneralRe: subclass all Pin
Blake Miller22-Aug-05 6:29
Blake Miller22-Aug-05 6:29 
Questiongraying/ungrayin not working? Pin
sayup22-Aug-05 1:42
sayup22-Aug-05 1:42 
AnswerRe: graying/ungrayin not working? Pin
Rage22-Aug-05 1:45
professionalRage22-Aug-05 1:45 
GeneralRe: graying/ungrayin not working? Pin
sayup22-Aug-05 3:59
sayup22-Aug-05 3:59 
GeneralRe: graying/ungrayin not working? Pin
Rage22-Aug-05 5:58
professionalRage22-Aug-05 5:58 
GeneralRe: graying/ungrayin not working? Pin
Bob Ciora22-Aug-05 6:53
Bob Ciora22-Aug-05 6:53 
You may have more luck taking over the UPDATE_COMMAND_UI function for that menu item. This is a pretty simple process, and doesn't require that the modeless child dialog know anything about the parent, or have to send some sort of signal to indicate that it's been hidden or unhidden. The UPDATE_COMMAND_UI handlers get fired whenever that menu item is about to be displayed.

I'm going to assume that you have a View menu with your various modeless sub-dialogs represented within this menu. In this case, I'm going to further assume that you have a command ID assigned for each dialog. For example, you may have IDC_VIEW_MYCHILD as the ID for the menu command to toggle show/hide some child dialog.

Using ClassWizard on the parent window/frame/etc., find the IDC_VIEW_MYCHILD command in the left hand pane. In the right hand pane, you'll then see entries for COMMAND and UPDATE_COMMAND_UI. Double-click the UPDATE_COMMAND_UI to create an Update handler for that menu item, and go edit that code.

Like I said, MFC will call the UPDATE handler for each menu item as it's getting ready to display the menu. This allows the user to customize each menu item separately via the UPDATE handler for that item.

In your case, using the codes above, you'd end up with a new function along the lines of CMyFrame::OnUpdateViewMychild. This function will receive a pointer to a CCmdUI object. CCmdUI has a lot of features, but for your purposes, you'd only need the Enable() method. If you have a pointer to the modeless dialog, then you can simply Enable or Disable the menu item based on the visibility status of the dialog, as such:

void CMyFrame::OnUpdateViewMychild(CCmdUI * pCmdUI)
{
    // Assumed m_pMyChild is the pointer to the modeless dialog:
    pCmdUI->Enable(!m_pMyChild->IsWindowVisible());
}

This code will enable (ungray) the menu item if the window is not visible, or disable (gray) the menu item if the window IS visible.

By using the UPDATE_COMMAND_UI handlers, you don't have to have the modeless child do any kind of mucking about with the main application menus or anything like that. This keeps them independent, and is a lot cleaner. In addition, one simple line of code takes care of your problem.


Hope this helps (and I hope I didn't "assume" too much Smile | :) )


Bob Ciora
GeneralProblem with Coordinates.... Pin
Ravi Sankar S22-Aug-05 0:36
Ravi Sankar S22-Aug-05 0:36 
GeneralRe: Problem with Coordinates.... Pin
ThatsAlok22-Aug-05 1:00
ThatsAlok22-Aug-05 1:00 
GeneralRe: Problem with Coordinates.... Pin
PravinSingh22-Aug-05 3:21
PravinSingh22-Aug-05 3:21 
GeneralCOCreateInstance() call failed Pin
Prasannajit Dash22-Aug-05 0:14
Prasannajit Dash22-Aug-05 0:14 
GeneralRe: COCreateInstance() call failed Pin
toxcct22-Aug-05 0:24
toxcct22-Aug-05 0:24 
GeneralRe: COCreateInstance() call failed Pin
dharani22-Aug-05 0:25
dharani22-Aug-05 0:25 
GeneralRe: COCreateInstance() call failed Pin
MailtoGops22-Aug-05 19:08
MailtoGops22-Aug-05 19:08 
GeneralCobList Error deleting last element !!!- HELP ME Pin
dharani22-Aug-05 0:08
dharani22-Aug-05 0:08 
GeneralRe: CobList Error deleting last element !!!- HELP ME Pin
Jack Puppy22-Aug-05 0:57
Jack Puppy22-Aug-05 0:57 
GeneralRe: CobList Error deleting last element !!!- HELP ME Pin
dharani22-Aug-05 1:49
dharani22-Aug-05 1:49 
Generalreading a data file n a specific format Pin
a_david12321-Aug-05 23:41
a_david12321-Aug-05 23:41 
GeneralRe: reading a data file n a specific format Pin
toxcct22-Aug-05 0:04
toxcct22-Aug-05 0:04 
GeneralRe: reading a data file n a specific format Pin
David Crow22-Aug-05 5:01
David Crow22-Aug-05 5:01 
GeneralRe: reading a data file n a specific format Pin
toxcct22-Aug-05 5:57
toxcct22-Aug-05 5:57 
QuestionCan anyone help me ~please~~~!! Pin
ebinaini21-Aug-05 23:31
ebinaini21-Aug-05 23:31 
AnswerRe: Can anyone help me ~please~~~!! Pin
Aamir Butt21-Aug-05 23:46
Aamir Butt21-Aug-05 23:46 
AnswerRe: Can anyone help me ~please~~~!! Pin
toxcct22-Aug-05 0:13
toxcct22-Aug-05 0:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.