Arranging Cascade the CDialogs in MFC with CascadeWindows function
How c开发者_开发百科an I arrange dialogs programmatically in MFC in cascade format, other than simply using SetWindowPos
based upon the position of the previously displayed window?
The Dialog position is to be loaded from the registry in my app, so we use:
SetWindowPos(NULL,x,y,cx,cy,SWP_NOZORDER);
...for the dialog. After that if we use the CascadeWindows function it doesn't seem to work for this Dialog, though it works for other dialogs in the same parent window. It seems the CascadeWindows
function has no effect on windows that have called SetWindowPos
; can anybody please confirm?
If so, do we have to use only SetWindowPos to arrange the dialog's cascade, or is there another way?
Check if your dialog is having window style: WS_EX_TOOLWINDOW
or WS_EX_TOPMOST
. CascadeWindows
will not arrange windows with that styles.
I tried an MFC sample dialog based application with the following code:
void CTestCascadeDlg::OnBnClickedOk()
{
this->SetWindowPos( NULL, 100,100,500,500, SWP_NOZORDER );
CascadeWindows( NULL, MDITILE_ZORDER, NULL, NULL, NULL );
}
And I could observe that my dialog was cascaded successfully.
精彩评论