RectDlg.cpp
上传用户:seaboy_04
上传日期:2013-02-24
资源大小:284k
文件大小:3k
源码类别:

其他行业

开发平台:

Visual C++

  1. // RectDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "DrawCli.h"
  5. #include "RectDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CRectDlg property page
  13. IMPLEMENT_DYNCREATE(CRectDlg, CPropertyPage)
  14. CRectDlg::CRectDlg() : CPropertyPage(CRectDlg::IDD)
  15. {
  16. //{{AFX_DATA_INIT(CRectDlg)
  17. m_bNoFill = FALSE;
  18. m_penSize = 0;
  19. m_nOrd = 0;
  20. //}}AFX_DATA_INIT
  21. }
  22. CRectDlg::~CRectDlg()
  23. {
  24. }
  25. void CRectDlg::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CPropertyPage::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(CRectDlg)
  29. DDX_Control(pDX, IDC_COMBO_TYPE, m_cTyp);
  30. DDX_Control(pDX, IDC_SPIN1, m_SpinCtrl);
  31. DDX_Check(pDX, IDC_NOFILL, m_bNoFill);
  32. DDX_Text(pDX, IDC_WEIGHT, m_penSize);
  33. DDV_MinMaxUInt(pDX, m_penSize, 0, 100);
  34. DDX_Text(pDX, IDC_EDIT_ORDER, m_nOrd);
  35. //}}AFX_DATA_MAP
  36. }
  37. BEGIN_MESSAGE_MAP(CRectDlg, CPropertyPage)
  38. //{{AFX_MSG_MAP(CRectDlg)
  39. ON_WM_PAINT()
  40. ON_BN_CLICKED(IDC_FILLCOLOR_BUTTON, OnFillcolorButton)
  41. ON_BN_CLICKED(IDC_LINECOLOR_BUTTON, OnLinecolorButton)
  42. ON_CBN_CLOSEUP(IDC_COMBO_TYPE, OnCloseupComboType)
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CRectDlg message handlers
  47. BOOL CRectDlg::OnInitDialog() 
  48. {
  49. CPropertyPage::OnInitDialog();
  50. m_SpinCtrl.SetRange(0, 100);
  51. m_SpinCtrl.SetBase(10);
  52. m_SpinCtrl.SetPos(1);
  53.   m_cTyp.SetCurSel(m_nTyp);
  54. return TRUE;  // return TRUE unless you set the focus to a control
  55.               // EXCEPTION: OCX Property Pages should return FALSE
  56. }
  57. void CRectDlg::OnPaint() 
  58. {
  59.    CPaintDC dc(this); // device context for painting
  60.    CBrush brush;
  61. if (!brush.CreateSolidBrush(m_FillColor))
  62. return;
  63.    CBrush* pOldBrush;
  64.    CPen pen;
  65.    if (!pen.CreatePen(PS_INSIDEFRAME,4,m_LineColor))
  66. return;
  67.    CPen* pOldPen;
  68.    CWnd* phwnd;
  69.    CDC*  pdc;
  70.    CRect rect;
  71.    phwnd=GetDlgItem(IDC_LINECOLOR);
  72.    pdc=phwnd->GetDC();
  73.    pOldPen = pdc->SelectObject(&pen);
  74.    phwnd->GetClientRect(&rect);
  75.    pdc->MoveTo(rect.left+2,rect.top+(rect.bottom-rect.top)/2);
  76.    pdc->LineTo(rect.right-3,rect.top+(rect.bottom-rect.top)/2);
  77.    pdc->SelectObject(pOldPen);
  78.    phwnd=GetDlgItem(IDC_FILLCOLOR);
  79.    pdc=phwnd->GetDC();
  80.    pOldBrush = pdc->SelectObject(&brush);
  81.    phwnd->GetClientRect(&rect);
  82.    pdc->Rectangle(rect);
  83.    pdc->SelectObject(pOldBrush);
  84. }
  85. void CRectDlg::OnFillcolorButton() 
  86. {
  87. CColorDialog cdlg;
  88. if (cdlg.DoModal()!=IDOK)
  89. return;
  90. m_FillColor = cdlg.GetColor();
  91. }
  92. void CRectDlg::OnLinecolorButton() 
  93. {
  94. CColorDialog cdlg;
  95. if (cdlg.DoModal()!=IDOK)
  96. return;
  97. m_LineColor = cdlg.GetColor();
  98. }
  99. void CRectDlg::OnCloseupComboType() 
  100. {
  101. // TODO: Add your control notification handler code here
  102. m_nTyp=m_cTyp.GetCurSel();
  103. }