其实要实现你的目的很简单:
void CMmmDlg::OnButton1()
{
// TODO: Add your control notification handler code here
RECT rc;
int x, y;
GetWindowRect(&rc);
x = rc.left+1;
y = rc.top+1;
::SetCursorPos(x,y);
}
我用你的代码测试过了
鼠标确实移动到了屏幕的左上角。
函数如下:
void CMmmDlg::OnButton1()
{
// TODO: Add your control notification handler code here
RECT rc;
int x, y;
GetWindowRect(&rc);
x = rc.left+1,
y = rc.top+1,
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, x, y, 0, 0);
}
MSDN中说:
The GetWindowRect function retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.