$#% MFC!!!

Started by
3 comments, last by i1977 21 years, 10 months ago
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!
Frederic FerlandStrategy First, Inc.http://www.strategyfirst.com
Advertisement
(M)icrosoft (F)ried (C)hicken is evil!!
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...
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.
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 †
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous

This topic is closed to new replies.

Advertisement