Solved

Hide CMainFrame window until splash screen disappears

Posted on 1998-08-27
5
552 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now