I have a dialog of type CPropertyPage
, where within the dialog I'm showing a CPropertySheet
object to display a couple of tabs.
Initially, when I was testing this dialog, I had it running as a separate dialog window (dialog.DoModal()
). When I am running it as a separate dialog window, the SetWindowPos()
function works, and I succesfully moved my the CPropertySheet
object to the correct location.
However, then I tried to incorporate this CPropertyPage
into another parent CPropertySheet
. This is when the SetWindowPos()
function doesn't work.
It seems like it ignores it when I have a CPropertySheet
on a CPropertyPage
, which is included in another CPropertySheet
. Does anybody have any idea why?
EDITED: Added extra code and pictures.
The code:
Pane 'pane.h':
CPropertySheet SheetSettings;
Top CPropertySheet
, top.h:
CMyDlg PageMyDlg;
Onsize(UINT nType, int cx, int cy);
Top CPropertySheet
, top.cpp:
Top::Top()
{
SheetSettings.AddPage(&PageMyDlg);
}
Top::Onsize(UINT nType, int cx, int cy)
{
if(SheetSettings.GetSafeHwnd())
{
SheetSettings.MoveWindow(0, 0, cx, cy);
CRect Rect;
SheetSettings.GetClientRect(Rect);
Rect.InflateRect(-2, -4, -2, -2);
SheetSettings.GetTabControl()->MoveWindow(Rect.left, Rect.top, Rect.Width(), Rect.Height());
SheetSettings.GetTabControl()->AdjustRect(FALSE, Rect);
if (Page12nc.GetSafeHwnd())
Page12nc.MoveWindow(Rect.left, Rect.top, Rect.Width(), Rect.Height());
}
// CPane holds the page where the CPropertySheet is drawn.
CPane::OnSize(nType, cx, cy);
}
Dialog 'CMyDlg', MyDlg.h:
CPropertySheet _dlgPropSheet;
Dialog 'CMyDlg', MyDlg.cpp:
CRect rcSheet;
_dlgPropSheet.GetParent()->GetWindowRect(&rcSheet);
ScreenToClient( &rcSheet );
// This goes wrong.
_dlgPropSheet.SetWindowPos( NULL, rcSheet.left+26, rcSheet.top+223, rcSheet.Width(), rcSheet.Height(), SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE );
This is what I get when I .doModal()
my CMyDlg
.
And this is what it draws when bottom is drawn on top.