• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 595
  • Last Modified:

Hide CMainFrame window until splash screen disappears

I've got an SDI app. i have a splash screen. i want now that
the main window does not appear until the splash screen
is destroyed.
I've tried:
  CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
      ShowWindow(SW_HIDE);
      ModifyStyle(0, (DWORD)WS_VISIBLE);
CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
      cs.style &= ~WS_VISIBLE;

none of this worked. my mainframe window should be
invisible until the splash screen is destroyed (where i call
AfxGetMainWnd->ShowWindow(SW_SHOW) to display my mainframe.
how can i do this?
0
wbk
Asked:
wbk
  • 3
  • 2
1 Solution
 
duneramCommented:
Possible solutions:
1) Hide your main window.  have your splash screen on destruction, post a message to your main window.  When you receive that message, make your window WS_VISIBLE, or use ShowWindow and show it at that point.

2)  Use the SetWindowPos Api in the OnInitDialog method to move your screen out of bounds (use getsystemmetrics(SM_CXSCREEN), and then set the top left to what isn't visible.  Then when your splash screen destructs, post a message to your main window.  Handle that message by moving your window into view with the SetWindowPos api.


0
 
wbkAuthor Commented:
hello durenam
i'd prefer the first solution
Possible solutions:
    1) Hide your main window. ...
  that's what i tried but i could not entirely hide the window it shows up for a very short
 moment i've tried the following to hide the window but none of it worked:
  CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
          ShowWindow(SW_HIDE);
          ModifyStyle(0, (DWORD)WS_VISIBLE);
    CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
          cs.style &= ~WS_VISIBLE;
so, do you know WHERE and HOW to hide the MainFrame window?

0
 
duneramCommented:
sure,

Go to your  main app source code's InitInstance routine

BOOL CYourApp::InitInstance()
{

Near the end of that function, find the

      // The one and only window has been initialized, so show and update it.
      m_pMainWnd->ShowWindow(SW_SHOW);
 Change that to SW_HIDE

You need to make that m_pMainWnd pointer available to your splash screen.  If its a separate window object, then you need to ensure the destructor of it tells your main window to 'SW_SHOW'.


0
 
wbkAuthor Commented:
Thanks,
     it's kind of strange I did this before but my main frame still is visible for a very short
     moment (not the whole just the frame and part of the inside)
     perhaps it has something to do that i have several views (used a splitter
    window for every view perhaps they try to show up after construction?


0
 
wbkAuthor Commented:
Thanks,
     it's kind of strange I did this before but my main frame still is visible for a very short
     moment (not the whole just the frame and part of the inside)
     perhaps it has something to do that i have several views (used a splitter
    window for every view perhaps they try to show up after construction?


0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now