Win32/MFC Get window rect from client rect

11,964

You're probably thinking of AdjustWindowRectEx(). Keep in mind, this is intended for use when creating a window - there's no guarantee that it will produce an accurate set of window dimensions for an existing window; for that, use GetWindowRect().

Share:
11,964

Related videos on Youtube

Adam McKee
Author by

Adam McKee

Updated on April 19, 2022

Comments

  • Adam McKee
    Adam McKee about 2 years

    I know there is a function somewhere that will accept a client rect and it will convert it into a window rect for you. I just can't find / remember it!

    Does anyone know what it is?

    It will do something similar to:

    const CRect client(0, 0, 200, 200);
    const CRect window = ClientRectToWindowRect(client);
    SetWindowPos(...)
    
  • Adam McKee
    Adam McKee over 15 years
    Nope, that takes client coordinates and converts them to screen coordinates.
  • Mark Ransom
    Mark Ransom over 15 years
    This doesn't account for the window borders. I had the same answer until I realized my mistake.