Solved

Hide CMainFrame window until splash screen disappears

Posted on 1998-08-27
5
562 Views
Last Modified: 2013-11-19
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
Comment
Question by:wbk
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
duneram earned 50 total points
ID: 1321360
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
 
LVL 1

Author Comment

by:wbk
ID: 1321361
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
 
LVL 2

Expert Comment

by:duneram
ID: 1321362
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
 
LVL 1

Author Comment

by:wbk
ID: 1321363
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
 
LVL 1

Author Comment

by:wbk
ID: 1321364
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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to calculate times for developing software? 8 67
Prevent this page from creating additional dialogs. 3 532
dog bark java program 15 95
Capture logon name 13 73
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question