Esempio n. 1
0
void CMainFrame::UpdateCursorInfoStatus()
{
    CStatic* pDrawingArea = (CStatic*)m_pView->GetDlgItem(IDC_IMAGEAREA);
    if (pDrawingArea == NULL)
    {
        return;
    }

	CString status;
	int x,y=0;
	m_pView->GetPixelPositionFromImage(&x,&y);
    
    CPoint dcPoint;
    CDC* pDC = pDrawingArea->GetDC();

	// Fix for Bug 20448
	if(pDC == NULL)
	{
		return;
	}
	
	HDC hdc = pDC->GetSafeHdc();
	if(hdc == NULL)
	{
		return;
	}
    
	GetCursorPos(&dcPoint);
    pDrawingArea->ScreenToClient(&dcPoint);
    COLORREF cr = pDC->GetPixel( dcPoint );
    m_pView->ReleaseDC( pDC );
	
    if( this == GetActiveWindow() &&
        x != -1 && y != -1 )
    {
        status.Format(
            "Cursor: (%d,%d) | RGB: (%u,%u,%u)",
            x,
            y,
            cr & 0xFF, 
            (cr & 0xFF00) >> 8, 
            (cr & 0xFF0000) >> 16 );
    }