Moving a Property Sheet

This is a discussion on Moving a Property Sheet within the Windows Programming forums, part of the Platform Specific Boards category; How can I move a property sheet created using PropertySheet()? I'm passing the HWND passed to my callback function (with ...

  1. #1
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361

    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.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Use GetParent(hWindow) for the first parameter of SetWindowPos.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. property sheet kinda not working
    By scwizzo in forum Windows Programming
    Replies: 6
    Last Post: 10-09-2007, 03:50 PM
  2. Creating a modeless property sheet
    By axr0284 in forum Windows Programming
    Replies: 6
    Last Post: 01-12-2005, 06:29 AM
  3. Dialog Box & Property Sheet :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 08-01-2002, 02:33 PM
  4. Passing a recordset pointer to a property sheet
    By Robert602 in forum Windows Programming
    Replies: 0
    Last Post: 05-14-2002, 08:45 AM
  5. Property Sheets :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 05-09-2002, 04:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21