How to disable subwindows when main window is disabled?

Volker Bartheld dr_versaeg at freenet.de
Mon Dec 10 12:49:43 PST 2007


Hi!

Let's suppose I want to automatically disable (=grey) all subwindows when
the main window ist disabled. I found MyDialog->Enable(false) not to be
sufficient - it just freezes all controls but doesn't grey them (probably
just event propagation is blocked). The example below works fine with
respect to disabling but the controls are not re-enabled back - somehow
wxUpdateUIEvent::Skip() makes them fall back to their previous (disabled)
state.

  void MyDialog::OnUpdateUI(wxUpdateUIEvent& evt)
  {
    evt.Enable(IsEnabled());
    if(!IsEnabled()) return;
    switch(evt.GetId())
    {
    // case ID_WHATEVER: /* custom enabling here */
    default: evt.Enable(true); evt.Skip(); break;
    }
  }

How do you do that efficiently without keeping a list of all your
control-IDs that are childs of a window?

Thanks a lot in advance and have a nice evening!

Volker

-- 
mailto:  V B A R T H E L D at G M X dot D E






More information about the wx-users mailing list