DIALOG.CPP
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:5k
源码类别:

Windows编程

开发平台:

Visual C++

  1. // dialog.cpp : implementation file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. #include "stdafx.h"
  13. #include "stdreg.h"
  14. #include "typeinfo.h"
  15. #include "dialog.h"
  16. #ifdef _DEBUG
  17. #undef THIS_FILE
  18. static char BASED_CODE THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CAboutDlg dialog used for App About
  22. class CAboutDlg : public CDialog
  23. {
  24. public:
  25. CAboutDlg();
  26. // Dialog Data
  27. //{{AFX_DATA(CAboutDlg)
  28. enum { IDD = IDD_ABOUTBOX };
  29. //}}AFX_DATA
  30. // Implementation
  31. protected:
  32. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  33. //{{AFX_MSG(CAboutDlg)
  34. virtual BOOL OnInitDialog();
  35. //}}AFX_MSG
  36. DECLARE_MESSAGE_MAP()
  37. };
  38. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  39. {
  40. //{{AFX_DATA_INIT(CAboutDlg)
  41. //}}AFX_DATA_INIT
  42. }
  43. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CDialog::DoDataExchange(pDX);
  46. //{{AFX_DATA_MAP(CAboutDlg)
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  50. //{{AFX_MSG_MAP(CAboutDlg)
  51. // No message handlers
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CAboutDlg message handlers
  56. BOOL CAboutDlg::OnInitDialog()
  57. {
  58. CDialog::OnInitDialog();
  59. CenterWindow();
  60. // TODO: Add extra about dlg initialization here
  61. return TRUE;  // return TRUE  unless you set the focus to a control
  62. }
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CStdRegSetupDlg dialog
  65. CStdRegSetupDlg::CStdRegSetupDlg(CWnd* pParent /*=NULL*/)
  66. : CDialog(CStdRegSetupDlg::IDD, pParent)
  67. {
  68. //{{AFX_DATA_INIT(CStdRegSetupDlg)
  69. // NOTE: the ClassWizard will add member initialization here
  70. //}}AFX_DATA_INIT
  71. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  72. }
  73. void CStdRegSetupDlg::DoDataExchange(CDataExchange* pDX)
  74. {
  75. CDialog::DoDataExchange(pDX);
  76. //{{AFX_DATA_MAP(CStdRegSetupDlg)
  77. DDX_Control(pDX, IDC_PROGRESS, m_ctlProgress);
  78. //}}AFX_DATA_MAP
  79. }
  80. BEGIN_MESSAGE_MAP(CStdRegSetupDlg, CDialog)
  81. //{{AFX_MSG_MAP(CStdRegSetupDlg)
  82. ON_WM_SYSCOMMAND()
  83. ON_WM_PAINT()
  84. ON_WM_QUERYDRAGICON()
  85. ON_BN_CLICKED(IDC_ADD_DATA_SOURCE, OnAddDataSource)
  86. ON_BN_CLICKED(IDC_INITIALIZE_DATA, OnInitializeData)
  87. //}}AFX_MSG_MAP
  88. END_MESSAGE_MAP()
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CStdRegSetupDlg message handlers
  91. BOOL CStdRegSetupDlg::OnInitDialog()
  92. {
  93. CDialog::OnInitDialog();
  94. CenterWindow();
  95. // Add "About..." menu item to system menu.
  96. // IDM_ABOUTBOX must be in the system command range.
  97. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  98. ASSERT(IDM_ABOUTBOX < 0xF000);
  99. CMenu* pSysMenu = GetSystemMenu(FALSE);
  100. CString strAboutMenu;
  101. strAboutMenu.LoadString(IDS_ABOUTBOX);
  102. if (!strAboutMenu.IsEmpty())
  103. {
  104. pSysMenu->AppendMenu(MF_SEPARATOR);
  105. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  106. }
  107. // TODO: Add extra initialization here
  108. return TRUE;  // return TRUE  unless you set the focus to a control
  109. }
  110. void CStdRegSetupDlg::OnSysCommand(UINT nID, LPARAM lParam)
  111. {
  112. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  113. {
  114. CAboutDlg dlgAbout;
  115. dlgAbout.DoModal();
  116. }
  117. else
  118. {
  119. CDialog::OnSysCommand(nID, lParam);
  120. }
  121. }
  122. void CStdRegSetupDlg::OnPaint()
  123. {
  124. CPaintDC dc(this); // device context for painting
  125. if (IsIconic())
  126. {
  127. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  128. // Center icon in client rectangle
  129. int xIcon = GetSystemMetrics(SM_CXICON);
  130. int yIcon = GetSystemMetrics(SM_CYICON);
  131. RECT rect;
  132. GetClientRect(&rect);
  133. int x = ((rect.right - rect.left + 1) - xIcon) / 2;
  134. int y = ((rect.bottom - rect.top + 1) - yIcon) / 2;
  135. // Draw the icon
  136. int nOldMapMode = dc.SetMapMode(MM_TEXT);
  137. dc.DrawIcon(x, y, m_hIcon);
  138. dc.SetMapMode(nOldMapMode);
  139. }
  140. }
  141. afx_msg HCURSOR CStdRegSetupDlg::OnQueryDragIcon()
  142. {
  143. return (HCURSOR) m_hIcon;
  144. }
  145. void CStdRegSetupDlg::OnAddDataSource()
  146. {
  147. ((CStdRegSetupApp*)AfxGetApp())->AddDataSource();
  148. }
  149. void CStdRegSetupDlg::OnInitializeData()
  150. {
  151. ((CStdRegSetupApp*)AfxGetApp())->InitializeData();
  152. }
  153. void CStdRegSetupDlg::OnOK()
  154. {
  155. // Exit the app
  156. CDialog::OnOK();
  157. }