|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Brett Cook
|
Apr 11, 2007 - 5:49 PM
|
Dear Tech Support,
Is there a way to make my main CFrameWnd (CMainFrame) to come up initially hidden? I tried turning off the WS_VISIBLE flag in the PreCreateWindow call, but the frame window still shows up after OnCreate is finished.
Any ideas?
Thanks, -Brett
|
|
Suhai Gyorgy
|
Apr 12, 2007 - 1:38 AM
|
Look in your application class’ InitInstance method. There should be either a pFrame->ShowWindow(SW_SHOW) or an pFrame->ActivateFrame(SW_SHOW) call. If you have the ActivateFrame call, it probably means that your application is set to handle window placement persistence, which I guess you dont need in your case. You should have pFrame->ShowWindow( SW_HIDE ) and pFrame->UpdateWindow() calls instead. But this will mean that your application window won’t be seen as long as you call ShowWindow(SW_SHOW) somewhere else in your code. Another solution would be to have every other initialization code in your InitInstance method, before calling ShowWindow(SW_SHOW) in it. What exactly you’d like to achieve with this hidden window?
|
|
Brett Cook
|
Apr 12, 2007 - 12:54 PM
|
Indeed, I am in fact currently doing what you describe: In CWinApp::InitInstance, I call ShowWindow( SW_HIDE ) after CMainFrame::OnCreate() is done, and then call ShowWindow( SW_SHOW ) after the rest of my application is finished initializing.
The problem arises when CMainFrame::OnCreate() returns, but before control is given back to CWinApp::InitInstance(). The UI frame is drawn and shows up briefly, until control is returned back to CWinApp::InitInstance() at which point I call the ShowWindow( SW_HIDE ), while the rest of the application initializes.
It is that flash of the UI between when CMainFrame::OnCreate() returns and control comes back to CWinApp::InitInstance(), that I want to avoid.
Is there anyway to tell the CMainFrame to come up initially hidden, and only show itself after I call the ShowWindow( SW_SHOW ) call?
Thanks, -Brett
|
|
Suhai Gyorgy
|
Apr 12, 2007 - 2:46 PM
|
I tried it with SDI sample of ProfUIS. InitInstance code little changed in it: { ...
CMainFrame* pFrame = new CMainFrame;
m_pMainWnd = pFrame;
// create and load the frame with its resources
pFrame->LoadFrame(IDR_MAINFRAME,
WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
NULL);
// The one and only window has been initialized, so show and update it.
pFrame->ShowWindow(SW_HIDE);
pFrame->UpdateWindow();
AfxMessageBox(_T("Initializing..."));
pFrame->ShowWindow(SW_SHOW);
pFrame->UpdateWindow();
return TRUE;
}
Testing it, mainframe doesn’t show up, not even for a blink, before pressing OK on MessageBox. So there must be something in your code that causes the window to show up.
|
|