What is the difference between GetClientRect and GetWindowRect in WinApi?

前端 未结 4 1718
灰色年华
灰色年华 2020-12-08 07:02

What of these should I use in InvalidateRect to refresh my window? And why?

4条回答
  •  难免孤独
    2020-12-08 07:42

    GetClientRect gets the coordinates of the window's client area. Specifically this is the area inside the window chrome and excludes the header etc. One of the comments on the MSDN page sums it up quite well:

    I would say that this function return size of the area that I can render to.

    GetWindowsRect gets the coordinates of the whole window. This includes the header, status bar etc. However according to a comment on the MSDN page

    Apps under Vista that are not linked with WINVER=6 will receive a misleading set of values here, that do not account for the extra padding of "glass" pixels Vista Aero applies to the window.

    So unless this have been fixed for Windows 7 double check the result you get and make sure you have the correct value of WINVER.

提交回复
热议问题