PropDlg.cpp
上传用户:spzyw88
上传日期:2020-05-08
资源大小:1874k
文件大小:4k
源码类别:

PropertySheet

开发平台:

Visual C++

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