如何获得完整的客户端正确性?
根据 MSDN,GetClientRect 函数实际上只适用于确定客户端宽度和宽度。高度,从左起&顶部始终为零。有没有办法获得完整的客户端坐标,包括左和右顶部(在屏幕空间或窗口空间中)?
The GetClientRect function, according to MSDN, is actually only good for determining the client width & height, since left & top are always zero. Is there a way to get the complete client coordinates, including left & top (either in screen space, or in window space)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许您需要 GetWindowRect。
Maybe you are needing GetWindowRect.
您正在寻找 GetWindowPlacement 函数。此函数返回一个 WINDOWPLACement 结构,该结构具有 rcNormalPosition 属性,该属性指定窗口处于正常(而不是最大化或最小化)显示状态时的位置。
编辑: itowilson 的答案实际上更干净,因为 WINDOWPLACMENT 结构还包含一堆您不需要的数据。
You're looking for the GetWindowPlacement function. This function returns a WINDOWPLACEMENT struct which has an rcNormalPosition property which specifies the window's position when it is in the normal (rather than maximized or minimized) display state.
EDIT: itowilson's answer is actually cleaner because the WINDOWPLACEMENT structure also contains a bunch of data you don't need.
在返回的 RECT 的左上角和右下角调用 ClientToScreen。如果您使用 MFC,CWnd 有 CWnd::ClientToScreen 的辅助重载,它将透明地为您完成此操作。
Call ClientToScreen on the top left and bottom right of the returned RECT. If you're using MFC, CWnd has a helper overload of CWnd::ClientToScreen that will do this transparently for you.