DynColorDlg.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // DynColorDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "IDE.h"
  5. #include "DynColorDlg.h"
  6. #include "SelectVariantDlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. extern void DrawColorButton(LPDRAWITEMSTRUCT lpDIS,COLORREF clrButton);
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CDynColorDlg dialog
  15. CDynColorDlg::CDynColorDlg(CWnd* pParent /*=NULL*/)
  16. : CDialog(CDynColorDlg::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CDynColorDlg)
  19. m_strCon = _T("");
  20. //}}AFX_DATA_INIT
  21. m_bUpDown = false;
  22. }
  23. void CDynColorDlg::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CDialog::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(CDynColorDlg)
  27. DDX_Text(pDX, IDC_DYNCOLORCON, m_strCon);
  28. DDX_Check(pDX, IDC_CHECK_UPDOWN, (int &)m_bUpDown);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(CDynColorDlg, CDialog)
  32. //{{AFX_MSG_MAP(CDynColorDlg)
  33. ON_WM_DRAWITEM()
  34. ON_BN_CLICKED(IDC_DYNCOLOR, OnDyncolor)
  35. ON_BN_CLICKED(IDC_CLRCONEDIT, OnClrconedit)
  36. //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CDynColorDlg message handlers
  40. void CDynColorDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
  41. {
  42. // TODO: Add your message handler code here and/or call default
  43. if (nIDCtl == IDC_DYNCOLOR)
  44. {
  45. DrawColorButton(lpDrawItemStruct,m_clr);
  46. }
  47. CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);
  48. }
  49. void CDynColorDlg::OnDyncolor()
  50. {
  51. CColorDialog dlg(m_clr);
  52. if(dlg.DoModal()==IDOK)
  53. {
  54. m_clr = dlg.GetColor();
  55. CButton* pButton = (CButton *)GetDlgItem(IDC_DYNCOLOR);
  56. pButton->ShowWindow(SW_HIDE);
  57. pButton->ShowWindow(SW_SHOW);
  58. }
  59. }
  60. void CDynColorDlg::OnClrconedit()
  61. {
  62. CFormatEditDlg dlg;
  63. dlg.m_strFormat = m_strCon;
  64. if ( dlg.DoModal() == IDOK )
  65. {
  66. m_strCon = dlg.m_strFormat;
  67. UpdateData(false);
  68. }
  69. }