ColorPickDialog.cpp
上传用户:zhoushen
上传日期:2022-06-15
资源大小:84k
文件大小:3k
- // ColourPickDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ColorPickDialog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CColorPickDlg dialog
- CColorPickDlg::CColorPickDlg(COLORREF& colorTxt, COLORREF& colorBk, CWnd* pParent /*=NULL*/)
- : CDialog(CColorPickDlg::IDD, pParent), m_ColorTxt(colorTxt), m_ColorBk(colorBk)
- {
- //{{AFX_DATA_INIT(CColorPickDlg)
- m_nMode = 1;
- //}}AFX_DATA_INIT
- m_crColour = m_ColorBk;
- m_ColourBox.SetTextColour(m_ColorTxt);
- m_ColourBox.SetBkColour(m_ColorBk);
- }
- void CColorPickDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CColorPickDlg)
- DDX_Control(pDX, IDC_COLOURPICKER, m_ColourBox);
- DDX_Radio(pDX, IDC_MODE1, m_nMode);
- //}}AFX_DATA_MAP
- DDX_ColourPicker(pDX, IDC_COLOURPICKER, m_crColour);
- }
- BEGIN_MESSAGE_MAP(CColorPickDlg, CDialog)
- //{{AFX_MSG_MAP(CColorPickDlg)
- ON_BN_CLICKED(IDC_MODE1, OnModeChange)
- //}}AFX_MSG_MAP
- ON_MESSAGE(CPN_SELENDOK, OnSelEndOK)
- ON_MESSAGE(CPN_SELENDCANCEL, OnSelEndCancel)
- ON_MESSAGE(CPN_SELCHANGE, OnSelChange)
- ON_MESSAGE(CPN_CLOSEUP, OnCloseUp)
- ON_MESSAGE(CPN_DROPDOWN, OnDropDown)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CColorPickDlg message handlers
- BOOL CColorPickDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- UpdateData(FALSE);
- OnModeChange();
- OnTrackColour();
- return TRUE; // return TRUE unless you set the focus to a control
- }
- /////////////////////////////////////////////////////////////////////////////
- // CColourPicker message handlers
- LONG CColorPickDlg::OnSelEndOK(UINT /*lParam*/, LONG /*wParam*/)
- {
- UpdateData(TRUE);
- TRACE0("Selection ended OKn");
- if (m_nMode)
- m_ColorBk = m_crColour;
- else
- m_ColorTxt = m_crColour;
- return TRUE;
- }
- LONG CColorPickDlg::OnSelEndCancel(UINT /*lParam*/, LONG /*wParam*/)
- {
- TRACE0("Selection cancelledn");
- return TRUE;
- }
- LONG CColorPickDlg::OnSelChange(UINT /*lParam*/, LONG /*wParam*/)
- {
- TRACE0("Selection changedn");
- return TRUE;
- }
- LONG CColorPickDlg::OnCloseUp(UINT /*lParam*/, LONG /*wParam*/)
- {
- TRACE0("Colour picker close upn");
- return TRUE;
- }
- LONG CColorPickDlg::OnDropDown(UINT /*lParam*/, LONG /*wParam*/)
- {
- TRACE0("Colour picker drop downn");
- return TRUE;
- }
- void CColorPickDlg::OnModeChange()
- {
- UpdateData(TRUE);
- m_ColourBox.SetSelectionMode(m_nMode ? CP_MODE_BK : CP_MODE_TEXT);
- }
- void CColorPickDlg::OnTrackColour()
- {
- UpdateData(TRUE);
- m_ColourBox.SetTrackSelection();
- }
- void CColorPickDlg::OnDisable()
- {
- UpdateData(TRUE);
- m_ColourBox.Invalidate();
- }
- void CColorPickDlg::OnChangeEdit()
- {
- CString str;
- m_ColourBox.SetDefaultText(str);
- m_ColourBox.SetCustomText(str);
- }