What is the difference between GetClientRect and GetWindowRect in WinApi?

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

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

4条回答
  •  抹茶落季
    2020-12-08 07:47

    The window rect includes the non-client area, i.e. the window borders, caption bar etc. The client rect does not.

    GetWindowRect returns a rect in screen coordinates whereas GetClientRect returns a rect in client coordinates.

    InvalidateRect receives a rect in client coordinates. If you want to invalidate your entire client area, then pass NULL to InvalidateRect. You could pass in the rect returned by GetClientRect, but it is far simpler and clearer to pass NULL.

提交回复
热议问题