Skip to content

Commit

Permalink
屏幕取色时实时显示颜色的RGB和十六进制值
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyang219 committed Aug 5, 2020
1 parent 8665e17 commit 9427689
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Binary file modified ColorPicker/ColorPicker.rc
Binary file not shown.
20 changes: 10 additions & 10 deletions ColorPicker/ColorPickerDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,6 @@ void CColorPickerDlg::SetColorHexText()

void CColorPickerDlg::SetPreview()
{
//CDC* pDC = m_preview.GetDC();
//CRect rect;
//m_preview.GetClientRect(rect);
//CBrush BGBrush, *pOldBrush;
//BGBrush.CreateSolidBrush(m_color);
//pOldBrush = pDC->SelectObject(&BGBrush);
//pDC->FillRect(&rect, &BGBrush);
//pDC->SelectObject(pOldBrush);
//BGBrush.DeleteObject();
//m_color_control.SetColor(m_color);
m_color_static.SetFillColor(m_color);
}

Expand Down Expand Up @@ -623,6 +613,16 @@ LRESULT CColorPickerDlg::OnColorPickCursorMove(WPARAM wParam, LPARAM lParam)
{
COLORREF color_tmp = wParam;
m_new_color_static.SetFillColor(color_tmp);

//
CString str_rgb;
str_rgb.Format(_T("%d, %d, %d"), GetRValue(color_tmp), GetGValue(color_tmp), GetBValue(color_tmp));
SetDlgItemText(IDC_CUR_COLOR_RGB_STATIC, str_rgb);

CString str_hex;
str_hex.Format(_T("#%.6x"), CColorConvert::RGB2Hex(GetRValue(color_tmp), GetGValue(color_tmp), GetBValue(color_tmp)));
SetDlgItemText(IDC_CUR_COLOR_HEX_STATIC, str_hex);

return LRESULT();
}

Expand Down
Binary file modified ColorPicker/resource.h
Binary file not shown.

0 comments on commit 9427689

Please sign in to comment.