PicSizeDlg.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // PicSizeDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "PicSizeDlg.h"
  5. extern void DrawColorButton(LPDRAWITEMSTRUCT lpDIS,COLORREF clrButton);
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CPicSizeDlg dialog
  13. CPicSizeDlg::CPicSizeDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CPicSizeDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CPicSizeDlg)
  17. m_nPictureHeight = 0;
  18. m_nPictureWidth = 0;
  19. m_nGridSize = 30;
  20. m_bGrid = FALSE;
  21. //}}AFX_DATA_INIT
  22. }
  23. void CPicSizeDlg::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CDialog::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(CPicSizeDlg)
  27. DDX_Text(pDX, IDC_PIC_HEIGHT, m_nPictureHeight);
  28. DDX_Text(pDX, IDC_PIC_WIDTH, m_nPictureWidth);
  29. DDX_Text(pDX, IDC_GRIDSIZE, m_nGridSize);
  30. DDX_Check(pDX, IDC_CHECK_SHOWGRID, m_bGrid);
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(CPicSizeDlg, CDialog)
  34. //{{AFX_MSG_MAP(CPicSizeDlg)
  35. ON_BN_CLICKED(IDC_BACKCOLOR, OnBackcolor)
  36. ON_WM_DRAWITEM()
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CPicSizeDlg message handlers
  41. void CPicSizeDlg::OnBackcolor()
  42. {
  43. // TODO: Add your control notification handler code here
  44. CColorDialog dlg(m_clrBack);
  45. if(dlg.DoModal()==IDOK)
  46. {
  47. m_clrBack = dlg.GetColor();
  48. CButton *pButton = (CButton *)GetDlgItem(IDC_BACKCOLOR);
  49. pButton->ShowWindow(SW_HIDE);
  50. pButton->ShowWindow(SW_SHOW);
  51. }
  52. }
  53. void CPicSizeDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
  54. {
  55. // TODO: Add your message handler code here and/or call default
  56. if(nIDCtl==IDC_BACKCOLOR) DrawColorButton(lpDrawItemStruct,m_clrBack);
  57. CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);
  58. }