ps_in_psDlg.cpp
上传用户:raowubin
上传日期:2007-01-02
资源大小:19k
文件大小:5k
源码类别:

PropertySheet

开发平台:

Visual C++

  1. // ps_in_psDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ps_in_ps.h"
  5. #include "ps_in_psDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CAboutDlg dialog used for App About
  13. class CAboutDlg : public CDialog
  14. {
  15. public:
  16. CAboutDlg();
  17. // Dialog Data
  18. //{{AFX_DATA(CAboutDlg)
  19. enum { IDD = IDD_ABOUTBOX };
  20. //}}AFX_DATA
  21. // ClassWizard generated virtual function overrides
  22. //{{AFX_VIRTUAL(CAboutDlg)
  23. protected:
  24. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  25. //}}AFX_VIRTUAL
  26. // Implementation
  27. protected:
  28. //{{AFX_MSG(CAboutDlg)
  29. //}}AFX_MSG
  30. DECLARE_MESSAGE_MAP()
  31. };
  32. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  33. {
  34. //{{AFX_DATA_INIT(CAboutDlg)
  35. //}}AFX_DATA_INIT
  36. }
  37. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CAboutDlg)
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  44. //{{AFX_MSG_MAP(CAboutDlg)
  45. // No message handlers
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CPs_in_psDlg dialog
  50. CPs_in_psDlg::CPs_in_psDlg(CWnd* pParent /*=NULL*/)
  51. : CDialog(CPs_in_psDlg::IDD, pParent)
  52. {
  53. //{{AFX_DATA_INIT(CPs_in_psDlg)
  54. // NOTE: the ClassWizard will add member initialization here
  55. //}}AFX_DATA_INIT
  56. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  57. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  58. }
  59. void CPs_in_psDlg::DoDataExchange(CDataExchange* pDX)
  60. {
  61. CDialog::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CPs_in_psDlg)
  63. // NOTE: the ClassWizard will add DDX and DDV calls here
  64. //}}AFX_DATA_MAP
  65. }
  66. BEGIN_MESSAGE_MAP(CPs_in_psDlg, CDialog)
  67. //{{AFX_MSG_MAP(CPs_in_psDlg)
  68. ON_WM_SYSCOMMAND()
  69. ON_WM_PAINT()
  70. ON_WM_QUERYDRAGICON()
  71. //}}AFX_MSG_MAP
  72. END_MESSAGE_MAP()
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CPs_in_psDlg message handlers
  75. BOOL CPs_in_psDlg::OnInitDialog()
  76. {
  77. CDialog::OnInitDialog();
  78. // Add "About..." menu item to system menu.
  79. // IDM_ABOUTBOX must be in the system command range.
  80. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  81. ASSERT(IDM_ABOUTBOX < 0xF000);
  82. CMenu* pSysMenu = GetSystemMenu(FALSE);
  83. if (pSysMenu != NULL)
  84. {
  85. CString strAboutMenu;
  86. strAboutMenu.LoadString(IDS_ABOUTBOX);
  87. if (!strAboutMenu.IsEmpty())
  88. {
  89. pSysMenu->AppendMenu(MF_SEPARATOR);
  90. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  91. }
  92. }
  93. // Set the icon for this dialog.  The framework does this automatically
  94. //  when the application's main window is not a dialog
  95. SetIcon(m_hIcon, TRUE); // Set big icon
  96. SetIcon(m_hIcon, FALSE); // Set small icon
  97. // TODO: Add extra initialization here
  98. // add pages
  99. m_sheet.AddPage(&m_page0);
  100. m_sheet.AddPage(&m_page1);
  101. // add pages to property sheet in property page
  102. m_page_with_sheet0.AddPage(&m_page2);
  103. m_page_with_sheet0.AddPage(&m_page3);
  104. m_page_with_sheet0.AddPage(&m_page4);
  105. m_page_with_sheet1.AddPage(&m_page5);
  106. m_page_with_sheet1.AddPage(&m_page6);
  107. // add property page with property sheet
  108. m_sheet.AddPage(&m_page_with_sheet0);
  109. m_sheet.AddPage(&m_page_with_sheet1);
  110. m_sheet.EnableStackedTabs( FALSE );
  111. m_sheet.Create(this, WS_CHILD | WS_VISIBLE , 0);
  112. m_sheet.ModifyStyleEx (0, WS_EX_CONTROLPARENT);
  113. m_sheet.ModifyStyle( 0, WS_TABSTOP );
  114. UpdateData(FALSE);
  115. return TRUE;  // return TRUE  unless you set the focus to a control
  116. }
  117. void CPs_in_psDlg::OnSysCommand(UINT nID, LPARAM lParam)
  118. {
  119. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  120. {
  121. CAboutDlg dlgAbout;
  122. dlgAbout.DoModal();
  123. }
  124. else
  125. {
  126. CDialog::OnSysCommand(nID, lParam);
  127. }
  128. }
  129. // If you add a minimize button to your dialog, you will need the code below
  130. //  to draw the icon.  For MFC applications using the document/view model,
  131. //  this is automatically done for you by the framework.
  132. void CPs_in_psDlg::OnPaint() 
  133. {
  134. if (IsIconic())
  135. {
  136. CPaintDC dc(this); // device context for painting
  137. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  138. // Center icon in client rectangle
  139. int cxIcon = GetSystemMetrics(SM_CXICON);
  140. int cyIcon = GetSystemMetrics(SM_CYICON);
  141. CRect rect;
  142. GetClientRect(&rect);
  143. int x = (rect.Width() - cxIcon + 1) / 2;
  144. int y = (rect.Height() - cyIcon + 1) / 2;
  145. // Draw the icon
  146. dc.DrawIcon(x, y, m_hIcon);
  147. }
  148. else
  149. {
  150. CDialog::OnPaint();
  151. }
  152. }
  153. // The system calls this to obtain the cursor to display while the user drags
  154. //  the minimized window.
  155. HCURSOR CPs_in_psDlg::OnQueryDragIcon()
  156. {
  157. return (HCURSOR) m_hIcon;
  158. }
  159. void CPs_in_psDlg::OnOK() 
  160. {
  161. // TODO: Add extra validation here
  162. if(UpdateData( TRUE ))
  163. CDialog::OnOK();
  164. }
  165. BOOL CPs_in_psDlg::UpdateData(BOOL bSaveAndValidate)
  166. {
  167. if(!CDialog::UpdateData(bSaveAndValidate))
  168. return FALSE;
  169. // check addition property sheet in property page
  170. if(m_page_with_sheet0)
  171. if(!m_page_with_sheet0.UpdateData(bSaveAndValidate))
  172. return FALSE;
  173. if(m_page_with_sheet1)
  174. if(!m_page_with_sheet1.UpdateData(bSaveAndValidate))
  175. return FALSE;
  176. // check main property sheet. Need when OK button press
  177. return m_sheet.GetActivePage()->UpdateData(bSaveAndValidate);
  178. }