I am wondering if, in order to move a (ms-windows-)window with the Win32 API 20 px to the right and 40 px downwards, the following
function call would be how to do it:
SetWindowPos(
/* hWnd */ hChildDlg2,
/* hWndInsertAfter */ (HWND) -1,
/* X */ 20,
/* Y */ 40,
/* cx */ -1,
/* cy */ -1,
/* uFlags */ SWP_NOSIZE | // Ignore cx, cy
SWP_NOZORDER // and hWndInsertAfter
);
I ask because it seems to me that there could be a function only taking a HWND and an x and y as parameters.
Yes, this is the normal way and the window will get a
WM_WINDOWPOSCHANGINGmessage (with the parameters that changed) There is also the olderMoveWindowbut it is less flexible and actually forces you to set the size.To properly save and restore window sizes you should use
GetWindowPlacementandSetWindowPlacementrespectively.