Posted By

pijon on 11/22/12


Tagged

win32


Versions (?)

Client Area Size with MoveWindow


 / Published in: C++
 

URL: http://suite101.com/article/client-area-size-with-movewindow-a17846

Calculate the size of all the window borders + client area.

  1. void ClientResize(HWND hWnd, int nWidth, int nHeight)
  2. {
  3. RECT rcClient, rcWind;
  4. POINT ptDiff;
  5. GetClientRect(hWnd, &rcClient);
  6. GetWindowRect(hWnd, &rcWind);
  7. ptDiff.x = (rcWind.right - rcWind.left) - rcClient.right;
  8. ptDiff.y = (rcWind.bottom - rcWind.top) - rcClient.bottom;
  9. MoveWindow(hWnd,rcWind.left, rcWind.top, nWidth + ptDiff.x, nHeight + ptDiff.y, TRUE);
  10. }

Report this snippet  

You need to login to post a comment.