#### Archived

This topic is now archived and is closed to further replies.

# $#% MFC!!! This topic is 5920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic. If you intended to correct an error in the post then please contact us. ## Recommended Posts This is probably very easy, but its getting late and I''m tired of searching... So... how the$@# can I make an MFC dialog-based application start with an invisible window? I''ve tried all sorts of things but none worked. I tried not setting the "Visible" flag in the dialog editor, overriding the WS_VISIBLE flag in PreCreateWindow() and a few other tricks like those. I''m out of ideas. Can anyone give me a few pointers? Thanks!

##### Share on other sites
(M)icrosoft (F)ried (C)hicken is evil!!

##### Share on other sites
I think I may know, by any chance is there a WinProc() function for an event handler (I tried MFC but couldn''t do it...) if there is just don''t run validateRect() then there will be not window... I think... or i''m crazy...

##### Share on other sites
There are a couple ways I can think of... override OnPaint() maybe, or look up WS_HIDE in MSDN. It all depends on what you''re trying to do but dlg->Show(... , SW_HIDE) should work.

##### Share on other sites
I just so happened to be reading CodeProject.com and read an article explaining how this is done...

Here''s how you do it:

Add a BOOL member to your dialog class and call it something, say m_visible.

Now in your dialog constructor set visible to false.

visible = false;
Now you need to override WM_WINDOWPOSCHANGING. You might have to change your message filtering options to have this message show up in the Class Wizard.

  void CTest_deleteDlg::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) {    if(!visible)        lpwndpos->flags &= ~SWP_SHOWWINDOW;    CDialog::OnWindowPosChanging(lpwndpos);}

That''s it. Now your modal dialog actually starts up in a hidden state. And when you want to make it visible this is what you need to do.

  visible = true;ShowWindow(SW_SHOW);

Note: this was taken right from the articel that can be found here:http://www.codeproject.com/useritems/dlgboxtricks.asp

Dave "Dak Lozar" Loeser †

1. 1
2. 2
3. 3
JoeJ
12
4. 4
5. 5

• 12
• 16
• 13
• 20
• 12
• ### Forum Statistics

• Total Topics
632176
• Total Posts
3004590

×