得到一个DC句柄然后GetPixel不可以吗~~

解决方案 »

  1.   

    void CTestDlg::OnButton1() 
    {
    // TODO: Add your control notification handler code here
    CPoint pt;
    HDC hDC = ::GetDC(NULL);
    pt.x=300;
    pt.y=400;
    COLORREF clr = ::GetPixel(hDC, pt.x, pt.y);
    CString RV,GV,BV;
    RV.Format("%d",GetRValue(clr));
    GV.Format("%d",GetGValue(clr));
    BV.Format("%d",GetBValue(clr));
    ::ReleaseDC(NULL, hDC);
    MessageBox(RV+","+GV+","+BV);
    }
      

  2.   

    HDC hDC = ::GetDC(NULL);
    int x = 300;
    int y = 400;
    COLORREF clr = ::GetPixel(hDC, x, y); 
      

  3.   

    GetPixel(::GetDC(NULL), 300, 400);
      

  4.   

    HWND hwnd=::GetForegroundWindow();
    HDC hDC=::GetDC(hwnd);
    COLORREF mycolor=::GetPixel(hDC,point.x,point.y);
      

  5.   

    COLORREF GetPixel(
      HDC hdc,    // handle to DC
      int nXPos,  // x-coordinate of pixel
      int nYPos   // y-coordinate of pixel
    );
     
    nXPos:要取象素点的x坐标
    nYPos:要取象素点的y坐标返回值是COLORREF类型   
      

  6.   

    GetPixel(::GetDC(NULL),   300,   400);
      

  7.   

    支持Prince_vegeta   的答案  通俗易懂!