MyFormView.cpp
上传用户:sisi1999
上传日期:2007-01-02
资源大小:39k
文件大小:4k
源码类别:

PropertySheet

开发平台:

Visual C++

  1. // MyFormView.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "PropPgFormView.h"
  5. #include "MyFormView.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CMyFormView
  13. IMPLEMENT_DYNCREATE(CMyFormView, CPropPgFormView)
  14. CMyFormView::CMyFormView()
  15. : CPropPgFormView(CMyFormView::IDD)
  16. {
  17. //{{AFX_DATA_INIT(CMyFormView)
  18. // NOTE: the ClassWizard will add member initialization here
  19. //}}AFX_DATA_INIT
  20. }
  21. CMyFormView::~CMyFormView()
  22. {
  23. }
  24. void CMyFormView::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CPropPgFormView::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CMyFormView)
  28. DDX_Control(pDX, IDC_OFFSET, m_ctlOffset);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(CMyFormView, CPropPgFormView)
  32. //{{AFX_MSG_MAP(CMyFormView)
  33. ON_BN_CLICKED(IDC_CLOSE, OnClose)
  34. ON_BN_CLICKED(IDC_RESIZE_FRAME, OnResizeFrame)
  35. ON_BN_CLICKED(IDC_DISABLE, OnDisable)
  36. ON_NOTIFY(UDN_DELTAPOS, IDC_OFFSET, OnDeltaposOffset)
  37. ON_BN_CLICKED(IDC_CENTER, OnCenter)
  38. ON_BN_CLICKED(IDC_ALLOW_PAGE_CHANGE, OnAllowPageChange)
  39. //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CMyFormView diagnostics
  43. #ifdef _DEBUG
  44. void CMyFormView::AssertValid() const
  45. {
  46. CPropPgFormView::AssertValid();
  47. }
  48. void CMyFormView::Dump(CDumpContext& dc) const
  49. {
  50. CPropPgFormView::Dump(dc);
  51. }
  52. #endif //_DEBUG
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CMyFormView message handlers
  55. BOOL CMyFormView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
  56. {
  57. if (!CPropPgFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext))
  58. return FALSE;
  59. m_PropSheet.AddPage(&m_Page1);
  60. m_PropSheet.AddPage(&m_Page2);
  61. m_PropSheet.AddPage(&m_Page3);
  62. // create a modeless property sheet
  63. if (!m_PropSheet.Create(this)) {
  64. DestroyWindow();
  65. return FALSE;
  66. }
  67. ((CButton*)GetDlgItem(IDC_CENTER))->SetCheck(m_PropSheet.m_Center);
  68. ((CButton*)GetDlgItem(IDC_ALLOW_PAGE_CHANGE))->SetCheck(m_PropSheet.m_bOKToLeaveTab);
  69. return TRUE;
  70. }
  71. void CMyFormView::OnClose() 
  72. {
  73. GetParentFrame()->SendMessage(WM_CLOSE);
  74. }
  75. void CMyFormView::OnResizeFrame() 
  76. {
  77. ResizeParentFrame();
  78. }
  79. void CMyFormView::OnDisable() 
  80. {
  81. CViewPropertyPage *pPg = (CViewPropertyPage*)m_PropSheet.GetActivePage(); 
  82. pPg->EnableControls(!pPg->IsEnabled());
  83. GetDlgItem(IDC_DISABLE)->SetWindowText((pPg->IsEnabled() ? "Disable" : "Enable") + CString(" page controls"));
  84. }
  85. void CMyFormView::OnDeltaposOffset(NMHDR* pNMHDR, LRESULT* pResult) 
  86. {
  87. NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  88. int iOffset = GetPropertySheetOffset();
  89. iOffset = pNMUpDown->iPos + pNMUpDown->iDelta;
  90. if (iOffset < 0)
  91. iOffset = 0;
  92. else if (iOffset > 100)
  93. iOffset = 100;
  94. if (iOffset != GetPropertySheetOffset())
  95. SetPropertySheetOffset(iOffset, TRUE);
  96. *pResult = 0;
  97. }
  98. void CMyFormView::OnInitialUpdate() 
  99. {
  100. CPropPgFormView::OnInitialUpdate();
  101. m_ctlOffset.SetPos(GetPropertySheetOffset());
  102. }
  103. BOOL CMyFormView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
  104. {
  105. if (TCN_SELCHANGE == ((LPNMHDR)lParam)->code) { // just changed tabs
  106. GetDlgItem(IDC_DISABLE)->SetWindowText((((CViewPropertyPage*)m_PropSheet.GetActivePage())->IsEnabled() ? "Disable" : "Enable") + CString(" page controls"));
  107. return TRUE;
  108. }
  109. return CPropPgFormView::OnNotify(wParam, lParam, pResult);
  110. }
  111. void CMyFormView::OnCenter() 
  112. {
  113. m_PropSheet.CenterControls(((CButton*)GetDlgItem(IDC_CENTER))->GetCheck());
  114. }
  115. void CMyFormView::OnAllowPageChange() 
  116. {
  117. m_PropSheet.AllowPageChange(((CButton*)GetDlgItem(IDC_ALLOW_PAGE_CHANGE))->GetCheck());
  118. }