如何判断点在矩形区域?

blithe_bird 2003-08-25 12:10:37
void Cxxx::OnRButtonUp(UINT nFlags, CPoint point)
{
CRect rect;
CStatic* p_bitmap=(CStatic*)GetDlgItem(IDC_PHOTO_ICON);
p_bitmap->GetClientRect(&rect);

rect.NormalizeRect();

if (rect.PtInRect(point))
{
.....

不知道相对坐标之类的东东,怎么可以使点和控件IDC_PHOTO_ICON获得一致的参考坐标????
...全文
574 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
whoo 2003-08-25
  • 打赏
  • 举报
回复
GetClientRect ==> GetWindowRect.
tonybaobao 2003-08-25
  • 打赏
  • 举报
回复
你的代码我不是很理解。要是我做,我就会:
RECT rect;
GetWindowRect(&rect);
ScreenToClient(&rect);
判断点的话,就这样咯
if(point.x>=rect.left&&point.x<=rect.right&&point.y>=rect.top&&point.y<=rect.bottom)
{
...
}
zhouyong0371 2003-08-25
  • 打赏
  • 举报
回复
void CPtInRectDlg::OnRButtonUp(UINT nFlags, CPoint point)
{
CRect rect;
CStatic* p_bitmap=(CStatic*)GetDlgItem(IDC_PHOTO_ICON);
p_bitmap->GetWindowRect(&rect);
ScreenToClient(&rect);

if (rect.PtInRect(point))
{
MessageBox("ok");
}

CDialog::OnRButtonUp(nFlags, point);
}

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧