MFC中如何得到对话框客户区中鼠标点下位置的坐标,具体代码。我的对话框中有一个图片,需要知道点下w
答案:3 悬赏:0
解决时间 2021-01-09 05:28
- 提问者网友:無理詩人
- 2021-01-09 02:06
MFC中如何得到对话框客户区中鼠标点下位置的坐标,具体代码。我的对话框中有一个图片,需要知道点下w
最佳答案
- 二级知识专家网友:妄饮晩冬酒
- 2021-01-09 03:13
//在对话窗标题处实时显示客户区内鼠标的坐标
void CTestDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str;
str.Format("X:%d Y:%d", point.x, point.y); //格式化鼠标坐标点信息并保存到CString型变量str中
SetWindowText(str); //更新程序窗口Edit控件文本
CDialog::OnMouseMove(nFlags, point);
}
//单击鼠标时,显示鼠标在客户区内的坐标
void CTestDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str;
str.Format("x = %d, y = %d", point.x, point.y);
AfxMessageBox(str,MB_ICONQUESTION);
CDialog::OnLButtonDown(nFlags, point);
}
void CTestDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str;
str.Format("X:%d Y:%d", point.x, point.y); //格式化鼠标坐标点信息并保存到CString型变量str中
SetWindowText(str); //更新程序窗口Edit控件文本
CDialog::OnMouseMove(nFlags, point);
}
//单击鼠标时,显示鼠标在客户区内的坐标
void CTestDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str;
str.Format("x = %d, y = %d", point.x, point.y);
AfxMessageBox(str,MB_ICONQUESTION);
CDialog::OnLButtonDown(nFlags, point);
}
全部回答
- 1楼网友:低音帝王
- 2021-01-09 04:28
在WM_LBUTTONUP消息的响应函数中,有一个point参数,这个就是鼠标点中的坐标。
- 2楼网友:拾荒鲤
- 2021-01-09 04:19
void CDialog1::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
lbPoint = point; //类成员函数,记录鼠标左键按下位置
CDialog::OnLButtonDown(nFlags, point);
}
追问:亲,你给我的是屏幕坐标
追答:ScreenToClient函数转换即可。
{
// TODO: Add your message handler code here and/or call default
lbPoint = point; //类成员函数,记录鼠标左键按下位置
CDialog::OnLButtonDown(nFlags, point);
}
追问:亲,你给我的是屏幕坐标
追答:ScreenToClient函数转换即可。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯