一、源代码
int x = GET_X_LPARAM(lParam);
int y = GET_Y_LPARAM(lParam);
TCHAR s[256];
_stprintf_s(s,_countof(s),_T("x坐标:%d,y坐标:%d"),x,y);
SetWindowText(hwndDlg, s);
二、函数解析
1、GET_X_LPARAM:获取鼠标x坐标(需要包含头文件)
2、GET_Y_LPARAM:获取鼠标y坐标(#include <Windowsx.h>)
3、_stprintf_s:将获取数值转换为字符串
4、SetWindowText:设置窗口标题
三、运行效果

欢迎关注编程有你公众号,每天学点编程知识














![MFC最详细入门教程[转载]](https://img-blog.csdnimg.cn/20191207225234302.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2ZyZWVraW5nMTAx,size_16,color_FFFFFF,t_70)



