要想捕获当前线程内(也就是当前CxxxApp)所有窗口上光标所在的像素颜色,需要重载CxxxApp的PreTranslateMessage函数,加:
if ( pMSG->message == WM_MOUSEMOVE)
{
CPoint ptScreen;
GetCursorPos(&ptScreen);
CWnd*DeskWnd = GetDesktopWindow();
CDC*DeskDC = DeskWnd->GetDC();
COLORREF clr = DeskDC->GetPixel(ptScreen);
DeskWnd->ReleaseDC(DeskDC);
CString strShow;
strShow.Format("%d", clr);
...
}
要想捕获当前屏幕任何地方的像素值,要先SetCapute,然后在使用上面的代码。
你给的分太少了吧!就算我会也不会回答的!还好我不会!
不是第一个问这个问题的人了……
在你的窗体里重载一个OnMouseMove函数
{
CDC *pDC;
COLORREF Color;
pDC=GetDC();
Color=pDC->GetPixel(point);
ReleaseDC(pDC);
}