您的位置:首页 > 其它

获取鼠标在屏幕上的坐标和颜色值(RGB)

2013-05-28 17:03 369 查看
xxxFun{
UINT bIsCheck = IsDlgButtonChecked(IDC_ONOFF);
if (bIsCheck)
{
SetTimer(1, 100, NULL);	//设置定时器(ID为1)
SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE ); // 设置窗口位置
}
else
{
KillTimer(1); // 关闭ID为1的定时器
SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
}
}
void CGetScreenPixel::OnTimer(UINT_PTR nIDEvent)
{
CDialog::OnTimer(nIDEvent);
CPoint point;
::GetCursorPos(&point);	// 获取鼠标位置(基于全屏幕)
m_xPos = point.x;
m_yPos = point.y;
UpdateData(FALSE);

CClientDC dc(NULL);
COLORREF color =  dc.GetPixel(point); // 获取鼠标位置的颜色值
m_R = color&0xFF;
m_G = (color>>8)&0xFF;
m_B = (color>>16)&0xFF;
UpdateData(FALSE);
}
里面有一些成员变量,如果有疑问的话,可以联系我....
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: