[code]void CPixelDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CClientDC dc(this);
COLORREF color;
color = dc.GetPixel(point);
SetDlgItemInt(IDC_CORD_X, point.x);
SetDlgItemInt(IDC_CORD_Y, point.y);
SetDlgItemInt(IDC_RED_VALUE, GetRValue(color));
SetDlgItemInt(IDC_GREEN_VALUE, GetGValue(color));
SetDlgItemInt(IDC_BLUE_VALUE, GetBValue(color));
CurrentPixelColor(color); // 현재 픽셀의 색상을 표시
SendCurrentColor(color); // 폼 뷰에 현재 색상을 전달
CDialog::OnMouseMove(nFlags, point);
}
void CPixelDlg::CurrentPixelColor(COLORREF color)
{
CRect rc;
CStatic* pFrame = (CStatic*)GetDlgItem(IDC_STATIC_COLOR);
pFrame->GetClientRect(rc);
CClientDC dc(pFrame);
CBrush br(color);
CBrush* pOld = dc.SelectObject(&br);
dc.FillRect(rc, &br);
dc.SelectObject(pOld);
}
void CPixelDlg::SendCurrentColor(COLORREF color)
{
CRect rc;
CStatic* pFrame =
(CStatic*)(GetParentFrame()->GetActiveView()->GetDlgItem(IDC_FORM_COLOR));
pFrame->GetClientRect(rc);
CClientDC dc(pFrame);
CBrush br(color);
CBrush* pOld = dc.SelectObject(&br);
dc.FillRect(rc, &br);
dc.SelectObject(pOld);
}
[/code]
{
CClientDC dc(this);
COLORREF color;
color = dc.GetPixel(point);
SetDlgItemInt(IDC_CORD_X, point.x);
SetDlgItemInt(IDC_CORD_Y, point.y);
SetDlgItemInt(IDC_RED_VALUE, GetRValue(color));
SetDlgItemInt(IDC_GREEN_VALUE, GetGValue(color));
SetDlgItemInt(IDC_BLUE_VALUE, GetBValue(color));
CurrentPixelColor(color); // 현재 픽셀의 색상을 표시
SendCurrentColor(color); // 폼 뷰에 현재 색상을 전달
CDialog::OnMouseMove(nFlags, point);
}
void CPixelDlg::CurrentPixelColor(COLORREF color)
{
CRect rc;
CStatic* pFrame = (CStatic*)GetDlgItem(IDC_STATIC_COLOR);
pFrame->GetClientRect(rc);
CClientDC dc(pFrame);
CBrush br(color);
CBrush* pOld = dc.SelectObject(&br);
dc.FillRect(rc, &br);
dc.SelectObject(pOld);
}
void CPixelDlg::SendCurrentColor(COLORREF color)
{
CRect rc;
CStatic* pFrame =
(CStatic*)(GetParentFrame()->GetActiveView()->GetDlgItem(IDC_FORM_COLOR));
pFrame->GetClientRect(rc);
CClientDC dc(pFrame);
CBrush br(color);
CBrush* pOld = dc.SelectObject(&br);
dc.FillRect(rc, &br);
dc.SelectObject(pOld);
}
[/code]
'Windows > MFC' 카테고리의 다른 글
CEdit SetWindowText, SetDlgItemText (0) | 2013.10.02 |
---|---|
CPropertySheet PSH_NOAPPLYNOW (0) | 2013.10.02 |
CListCtrl NM_LISTVIEW Click event (0) | 2013.10.02 |
Modeless Window (0) | 2013.10.02 |
CToolTipCtrl (0) | 2013.10.02 |