locked
Very very stupid question about client rect RRS feed

  • Question

  • Hi,

    Sorry to ask this but I never realize something until today and maybe I am really tired to ask this.
    So here is my question :

    When window is resized we receive a few WM_SIzE message and if you trace them you can see for instance on an emulator :

    case WM_SIZE:
                lWidth = GET_X_LPARAM(lParam);
                lHeight = GET_Y_LPARAM(lParam);
                GetClientRect(hWnd, &rc);
                ATLTRACE(_T("WM_SIZE(%d,%d), rc(%d,%d,%d,%d)\r\n"),
                    lWidth, lHeight, rc.left, rc.top,rc.right, rc.bottom);
                break;

    WM_SIZE(240,268), rc(0,0,240,268)
    WM_SIZE(240,268), rc(0,0,240,268)

    So we have a width of 240 and a height of 268 BUT when I look at GetClienRect I can see that left pos is 0 and right is 240.
    What I don't understand if the fact since client rect starts with 0 why it's not (0,0, 239, 267) ?


    Monday, August 17, 2009 6:32 PM

Answers

  • If you take a look at the documentation of GetClientRect, you will see that the following: The left and top members are zero. The right and bottom members contain the width and height of the window. So the right member in case of GetClientRect does not return the right coordinate of the client rectangle but its width and the same is true for the height, instead of the bottom coordinate.
    • Marked as answer by Shifusan Tuesday, August 18, 2009 6:29 AM
    Monday, August 17, 2009 8:40 PM