If there is a child window location of the mouse, whether to use the parent window of the DC to get color, return is white, is the window background color?
If the DC to get a child window, can normal to color,
CodePudding user response:
Can GetDC (NULL) using DC for a location point of the screen pixelBelow is the use of dialog box, on a static control IDC_STATIC1, use a timer take code
Void CDlg6Dlg: : OnTimer (UINT nIDEvent)
{
//TODO: Add your message handler code here and/or call the default
If (nIDEvent==1)
{
POINT ptCurs={1, 1};
COLORREF cf=(a COLORREF) (1);
//get the color of the point on the screen
HDC hScreenDC=: : GetDC (NULL);
If (hScreenDC)
{
If (GetCursorPos (& amp; PtCurs))
{
Cf=GetPixel (hScreenDC ptCurs. X, ptCurs. Y);
}
: : ReleaseDC (NULL, hScreenDC);
}
The CWnd * pCtrl=GetDlgItem (IDC_STATIC1);
If (pCtrl)
{
CRect rcRect;
PCtrl - & gt; GetClientRect (& amp; RcRect);
The CDC * pDstDC=pCtrl - & gt; GetDC ();
PDstDC - & gt; FillSolidRect (& amp; RcRect, 0);//fill black
RcRect. DeflateRect (3, 3);
PDstDC - & gt; FillSolidRect (& amp; RcRect, RGB (255, 255, 255));//fill white
RcRect. DeflateRect (3, 3);
PDstDC - & gt; FillSolidRect (& amp; RcRect, cf);//fill for the color of the
PCtrl - & gt; The ReleaseDC (pDstDC);
}
}
CDialog: : OnTimer (nIDEvent);
}
CodePudding user response:
I need to monitor a program of a coordinate color is red, red is a warning, requirements to minimize work properly even when the program, so can't pick up the screen color way to monitor the input the program's main window handle, coordinate, color, and then in the timer,CodePudding user response:
You sure it will minimize paint?CodePudding user response:
Seems to only take the color values are displayed on the screen window, the window to minimize or obscured take less than, is the boh?CodePudding user response: