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 |
|
Charles Bisbee
|
Jul 2, 2010 - 3:47 PM
|
I have a window based on CExtResizableDialog. I need to create it with it hidden. When I create it, it flashes until ShowWindow(SW_HIDE) is called. I have tried calling ShowWindow(SW_HIDE) in both PreInitDialog and InitDialog for the derived class. The call in PreInitDialog seems to be too early (the dialog is still displayed.) The call in InitDialog is better than a call after create finishes but still results in a flash. How do I stop the Flash Thanks
|
|
Charles Bisbee
|
Jul 8, 2010 - 4:23 PM
|
Call me dumb. The WS_VISIBLE was on. Thanks for your patience
|
|
Technical Support
|
Jul 3, 2010 - 5:33 AM
|
Modal dialogs in MFC are initially visible. So, the correct solution would be to create a non-modal dialog. You should set the Visible property of your dialog template resource to false to make your dialog initially hidden. You don’t have to invoke any code to hide it. Then you should create your dialog using its Create() method rather than its DoModal() method. That’s all. But if you need a modal dialog type, then you should emulate the modal message loop manually. Here is the sample source code for all the tasks:
// this is a probably pointer to your main frame or main dialog window (it must be popup window)
CWnd * pParentWindowOfYourDialog = . . .
CYourDialog dlg( . . . );
if( ! dlg.Create( CYourDialog::IDD, pParentWindowOfYourDialog ) )
return . . .
//
// That’s all. Invisible dialog was created successfully.
// Now we will run the modal message loop for it:
//
pParentWindowOfYourDialog->EnableWindow( FALSE );
while( dlg.GetSafeHwnd() != NULL )
CExtPopupMenuWnd::PassMsgLoop( true );
pParentWindowOfYourDialog->EnableWindow( TRUE );
The code above works like a modal dialog for your app users. But this dialog is not exactly the same as a modal dialog. If you need the modal result of this dialog ( IDOK , IDCANCEL , etc), you should save it in some property of your dialog manually.
|
|