-
Moving a Property Sheet
How can I move a property sheet created using PropertySheet()? I'm passing the HWND passed to my callback function (with the PSCB_INITIALIZED message) to SetWindowPos(), but this call fails. GetLastError() is 0. I'm using this code to try and center the property sheet on the screen, it works for other windows, but not property sheets: Code:
BOOL CenterWindow(HWND hWindow)
{
RECT WindowRect;
BOOL Result = GetWindowRect(hWindow, &WindowRect);
if (Result != FALSE)
{
int ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int ScreenHeight = GetSystemMetrics(SM_CYSCREEN);
int WindowWidth = WindowRect.right - WindowRect.left;
int WindowHeight = WindowRect.bottom - WindowRect.top;
Result = SetWindowPos(hWindow, 0, ScreenWidth / 2 - WindowWidth / 2,
ScreenHeight / 2 - WindowHeight / 2, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
return !Result;
}
return FALSE;
}
Any help would be appreciated.
-
Use GetParent(hWindow) for the first parameter of SetWindowPos.