Thread: MoveWindow

  1. #1
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718

    MoveWindow

    If I change the size of a window using MoveWindow to 400x250, the entire window (including title bar and borders) is made to be 400x250. Is there any way to size it so that the actual client area is 400x250?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Nevermind. Figured it out.

    Code:
    RECT	rect;
    int	borderWidth;
    int	borderHeight;
    
    MoveWindow( g_hWnd, 100, 100, 400, 250, FALSE );	
    	
    GetClientRect( g_hWnd, &rect );
    borderWidth = 400 - ( rect.right - rect.left );
    borderHeight = 250 - ( rect.bottom - rect.top );
    
    MoveWindow( g_hWnd, 100, 100, WINDOW_WIDTH + borderWidth, WINDOW_HEIGHT + borderHeight, FALSE );
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Hmmmm, thanks for thinking out loud. I like your way of determining the border size

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Heh. I'm sure that someone will point out a better way to do it, but that seems to be working fine for me.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    That's actually the way I always do things. Find the current client size, and use the desired client size to figure out how much to expand the window.

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Check out this handy function. AdjustWindowRect( );

    http://msdn.microsoft.com/library/de...WindowRect.asp
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  7. #7
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    That method is good for sizing before the creation of the window, but I find it a pain in the ass to write down the window styles over and over.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  8. #8
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Why not just combine them into one DWORD much like you specify when creating the window with bitwise OR.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  9. #9
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    GetSystemMetrics() can return the thickness of the windows frame.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  10. #10
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>but I find it a pain in the ass to write down the window styles over and over.

    dwStyle = GetWindowLong (hWnd, GWL_STYLE);
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed