SetWindowPos does nothing
-
Hi, I try to resize a Custom Control in the OnSize Function of my Views OnSize Function. There is no Error, but nothing happens:
afx_msg void CCustomView::OnSize(UINT nType, int cx, int cy) {
if (::IsWindow(m\_datagrid)) { m\_datagrid.SetWindowPos(&wndTopMost, 12, 48, 500, 500, SWP\_NOZORDER | SWP\_NOMOVE); } CView::OnSize(nType, cx, cy);
}
What am I do wrong? m_datagrid.SetWindowPos is executed, I checked it by debugging. Thank you for your help, Johannes
-
Hi, I try to resize a Custom Control in the OnSize Function of my Views OnSize Function. There is no Error, but nothing happens:
afx_msg void CCustomView::OnSize(UINT nType, int cx, int cy) {
if (::IsWindow(m\_datagrid)) { m\_datagrid.SetWindowPos(&wndTopMost, 12, 48, 500, 500, SWP\_NOZORDER | SWP\_NOMOVE); } CView::OnSize(nType, cx, cy);
}
What am I do wrong? m_datagrid.SetWindowPos is executed, I checked it by debugging. Thank you for your help, Johannes
What are you wanting to happen? You use wndTopMost but it's ignored because of SWP_NOZORDER. You use x and y positions but they're ignored because of SWP_NOMOVE. That leaves resize :)
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
What are you wanting to happen? You use wndTopMost but it's ignored because of SWP_NOZORDER. You use x and y positions but they're ignored because of SWP_NOMOVE. That leaves resize :)
Mark Salsbery Microsoft MVP - Visual C++ :java:
Yes, it would have been better if I posted the code without the flags. When I do not use the Flags it`s the same thing: My Custom control is not be resized and not moved, and this is what I want it to do...
-
Yes, it would have been better if I posted the code without the flags. When I do not use the Flags it`s the same thing: My Custom control is not be resized and not moved, and this is what I want it to do...
If you want to move and resize, just use MoveWindow(). The other problem may be where you're doing it from. The view may not get a WM_SIZE message after the child window you're moving is created (until the next time the view is resized). Put a breakpoint on the SetWindowPos() call to check.
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
If you want to move and resize, just use MoveWindow(). The other problem may be where you're doing it from. The view may not get a WM_SIZE message after the child window you're moving is created (until the next time the view is resized). Put a breakpoint on the SetWindowPos() call to check.
Mark Salsbery Microsoft MVP - Visual C++ :java:
Hi Mark, thank you. With MoveWindow() it works!