Create children initially hidden

Vadim Zeitlin vadim at wxwindows.org
Mon Apr 2 15:05:31 PDT 2007


On Mon, 2 Apr 2007 12:13:25 +0200 Volker Bartheld <dr_versaeg at freenet.de> wrote:

VB> Probably, I still didn't get it. Here's the shortes version of my code
VB> that reproduces the problem (for wxidleonceevthandler.cpp/h see below):
VB> 
VB> #include <wx/wx.h>
VB> #include "wxidleonceevthandler.h"
VB> class MyDialog : public wxDialog
VB> {
VB> public:
VB>   MyDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxMINIMIZE_BOX, const wxString& name=wxT("dialogBox")) { Create(parent, id, title, pos, size, style, name); }
VB>   ~MyDialog() { delete m_idleonce; }
VB>   bool Create(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxMINIMIZE_BOX, const wxString& name=wxT("dialogBox"))
VB>   {
VB>     Hide();
VB>     bool b=wxDialog::Create(NULL, wxID_ANY, title, pos);
VB>     SetIcon(wxICON(tiny));
VB>     SetSizer(new wxBoxSizer(wxVERTICAL));
VB>     GetSizer()->Add(new wxButton(this, wxID_OK, _("&OK")), 0, wxALL, 5);
VB>     GetSizer()->SetSizeHints(this);
VB>     m_idleonce=new wxIdleOnceEvtHandler(this);
VB>     return b;
VB>   }
VB>   void OnClose(wxCloseEvent &event)   { if(IsModal()) EndModal(0); else Destroy(); }
VB>   void OnIdleOnce(wxIdleEvent&)
VB>   {
VB>     wxSleep(1); // MyDialog shown for one second - why? Should be hidden...
VB>     Iconize();
VB>   }
VB> private:
VB>   wxIdleOnceEvtHandler* m_idleonce;
VB>   DECLARE_EVENT_TABLE()
VB> };
VB> BEGIN_EVENT_TABLE(MyDialog, wxDialog)
VB> EVT_IDLE_ONCE(MyDialog::OnIdleOnce)
VB> END_EVENT_TABLE()
VB> class MyApp : public wxApp
VB> {
VB> public: 
VB>   virtual bool OnInit()
VB>   {
VB>     if(!wxApp::OnInit()) return false;
VB>     MyDialog TheDialog(NULL, wxID_ANY, _T("Test Dialog"));
VB>     TheDialog.ShowModal();
VB>     return false;
VB>   }
VB> };  
VB> IMPLEMENT_APP(MyApp)
VB> 
VB> What happens is, that the dialog still flashes up for a short time
VB> (between MyDialog::Create() and MyDialog::OnIdleOnce())

 But isn't OnIdleOnce() shown after ShowModal()? I.e. the dialog is
initially hidden but then you show it -- so it becomes visible.

VB> So it more or less boils down to one question: How can I create a modal
VB> dialog, that starts minimized in the taskbar without initially popping
VB> up to the screen for a short time. I wasn't able to solve that and I'm not
VB> sure how your advice helps me there.

 I don't think it's possible to do what you want and IMO it really doesn't
make sense. A modal dialog is for something absolutely requiring the user
attention and how can you request the attention while being minimized? If
you don't need the user immediate answer, don't make the dialog modal. If
you do make it modal, don't minimize it.

 Regards,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/





More information about the wx-users mailing list