CWndSetWindowPos does not move child window

  • Thread starter Thread starter Geoyar
  • Start date Start date
G

Geoyar

Guest
Visual Studio 2017 Community 15.7.6 under Windows 7 Pro SP1

I have MFC dialog based app and in it a a second, modeless dialog that I show in response to button click in the main dialog. the style of that second dialog is 'Child'.

The code copied from VS 2013 Ultimate, is:


if (!IsWindow(m_dlgChild.m_hWnd))
{
// Create res chart dlg
BOOL bRes = m_dlgChild.Create(MAKEINTRESOURCE(IDD_DLGCHILD), this);
}

if (!m_dlgChild.IsWindowVisible())
{
CRect rectWC;
m_dlgChild.GetWindowRect(&rectWC);
CSize szWC = rectWC.Size();
BOOL bRes = m_dlgChild.SetWindowPos(&CWnd::wndTopMost, 20, 20, , szWC.cx,

szWC.cy, SWP_HIDEWINDOW);

m_dlgChild.ShowWindow(SW_SHOW);
}




This code worked just fine in Visual Studio 2013 Ultimate and does not move anything in Visual Studio 2017 Community.

Changes of SWP f;ags or Z-order do not move the child dialog. bRess is always TRUE.

What does move the child is (found on Internet)

BOOL bRes = m_dlgChild.SetWindowPos(NULL, 20, 20, 0, 0, SWP_NOZORDER | SWP_NOSIZE);

or

m_dlgChild.MoveWindow(20, 20, szWC.cx, szWC.cy, FALSE);

So what happened with CWnd::SetWindowPos between VS 2013 and VS 2017?

Continue reading...
 
Back
Top