如何确定 POINT 是否在按钮区域内
如何确定 POINT 是否在按钮区域内? POINT 位于屏幕坐标中,我有按钮所在窗口的句柄和按钮的句柄。 我尝试了 ::ScreenToClient(okBtnH , &tempPosition) ,其中 okBtnH 是按钮的句柄, tempPosition 是屏幕坐标中的 POINT 结构。但它不起作用。 除了手动计算按钮的屏幕位置然后将其与 POINT str 进行比较之外,还有什么方法可以做到这一点?
how to determine if a POINT is inside the area of a button?
the POINT is in screen coordinates , and I have the handle of the window in which the button is and the handle of the button.
I tried ::ScreenToClient(okBtnH , &tempPosition) where okBtnH is the handle of the button and the tempPosition is a POINT structure in screen coordinates. but it doesn't work.
Is there any way to do this except manual calculation of the screen position of the button and then compare it with the POINT str ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确定
okBtnH
是按钮控件的句柄,而不仅仅是它的ID吗?如果ScreenToClient
因“无效句柄”而失败,那么您的句柄可能无效。Are you sure that
okBtnH
is a handle for the button control, and not just its ID? IfScreenToClient
is failing with "Invalid Handle" then your handle is likely invalid.如果您使用的是MFC,那么您只需调用成员函数ScreenToClient即可。为什么叫全局版,确定手柄是按钮手柄?
If you are using MFC then you can just call the member function ScreenToClient. Why do you call the global version and are you sure the handle is the buttons handle?