我是 MFC 的新手,正在制作一个简单的程序,它将不断更新两个编辑框。编辑框包含鼠标光标的 x 和 y 坐标。该程序仅在单击开始按钮时开始抓取光标坐标,并且应该在单击停止按钮时停止。但是,只要我单击开始按钮,整个窗口就会冻结。
这是我到目前为止所拥有的:
//Way up high in the code:
#include <windows.h>
//way down low in the code
void CmfcpixelDlg::OnBnClickedButtonStart()
{
POINT p;
CString x;
CString y;
int px;
int py;
while(stop == false){
GetCursorPos(&p);
px = p.x;
//convert x coordinate to a CString
x.Format(L"%d", px);
//convert y coordinate to a CString
py = p.y;
y.Format(L"%d", py);
m_x.SetWindowTextW(x.GetBuffer());
m_y.SetWindowTextW(y.GetBuffer());
}
}