Property2Dlg.cpp
上传用户:sjtdsyy
上传日期:2020-03-26
资源大小:76k
文件大小:4k
源码类别:

PropertySheet

开发平台:

Visual C++

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