Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

276 lines
6.5 KiB

  1. // MSConfigDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "MSConfig.h"
  5. #include "MSConfigDlg.h"
  6. #include "MSConfigState.h"
  7. #include "AutoStartDlg.h"
  8. #include <htmlhelp.h>
  9. extern CMSConfigApp theApp;
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CAboutDlg dialog used for App About
  17. class CAboutDlg : public CDialog
  18. {
  19. public:
  20. CAboutDlg();
  21. // Dialog Data
  22. //{{AFX_DATA(CAboutDlg)
  23. enum { IDD = IDD_ABOUTBOX };
  24. //}}AFX_DATA
  25. // ClassWizard generated virtual function overrides
  26. //{{AFX_VIRTUAL(CAboutDlg)
  27. protected:
  28. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  29. //}}AFX_VIRTUAL
  30. // Implementation
  31. protected:
  32. //{{AFX_MSG(CAboutDlg)
  33. //}}AFX_MSG
  34. DECLARE_MESSAGE_MAP()
  35. };
  36. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  37. {
  38. //{{AFX_DATA_INIT(CAboutDlg)
  39. //}}AFX_DATA_INIT
  40. }
  41. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  42. {
  43. CDialog::DoDataExchange(pDX);
  44. //{{AFX_DATA_MAP(CAboutDlg)
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  48. //{{AFX_MSG_MAP(CAboutDlg)
  49. // No message handlers
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CMSConfigDlg dialog
  54. CMSConfigDlg::CMSConfigDlg(CWnd* pParent /*=NULL*/)
  55. : CDialog(CMSConfigDlg::IDD, pParent)
  56. {
  57. //{{AFX_DATA_INIT(CMSConfigDlg)
  58. // NOTE: the ClassWizard will add member initialization here
  59. //}}AFX_DATA_INIT
  60. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  61. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  62. }
  63. void CMSConfigDlg::DoDataExchange(CDataExchange* pDX)
  64. {
  65. CDialog::DoDataExchange(pDX);
  66. //{{AFX_DATA_MAP(CMSConfigDlg)
  67. // NOTE: the ClassWizard will add DDX and DDV calls here
  68. //}}AFX_DATA_MAP
  69. }
  70. BEGIN_MESSAGE_MAP(CMSConfigDlg, CDialog)
  71. //{{AFX_MSG_MAP(CMSConfigDlg)
  72. ON_WM_SYSCOMMAND()
  73. ON_WM_PAINT()
  74. ON_WM_QUERYDRAGICON()
  75. ON_BN_CLICKED(IDC_BUTTONAPPLY, OnButtonApply)
  76. ON_BN_CLICKED(IDC_BUTTONCANCEL, OnButtonCancel)
  77. ON_BN_CLICKED(IDC_BUTTONOK, OnButtonOK)
  78. ON_NOTIFY(TCN_SELCHANGE, IDC_MSCONFIGTAB, OnSelChangeMSConfigTab)
  79. ON_NOTIFY(TCN_SELCHANGING, IDC_MSCONFIGTAB, OnSelChangingMSConfigTab)
  80. ON_WM_CLOSE()
  81. ON_WM_HELPINFO()
  82. ON_BN_CLICKED(IDC_BUTTONHELP, OnButtonHelp)
  83. //}}AFX_MSG_MAP
  84. END_MESSAGE_MAP()
  85. /////////////////////////////////////////////////////////////////////////////
  86. // CMSConfigDlg message handlers
  87. BOOL CMSConfigDlg::OnInitDialog()
  88. {
  89. CDialog::OnInitDialog();
  90. // Add "About..." menu item to system menu.
  91. // IDM_ABOUTBOX must be in the system command range.
  92. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  93. ASSERT(IDM_ABOUTBOX < 0xF000);
  94. CMenu* pSysMenu = GetSystemMenu(FALSE);
  95. if (pSysMenu != NULL)
  96. {
  97. CString strAboutMenu;
  98. strAboutMenu.LoadString(IDS_ABOUTBOX);
  99. if (!strAboutMenu.IsEmpty())
  100. {
  101. pSysMenu->AppendMenu(MF_SEPARATOR);
  102. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  103. }
  104. }
  105. // Set the icon for this dialog. The framework does this automatically
  106. // when the application's main window is not a dialog
  107. SetIcon(m_hIcon, TRUE); // Set big icon
  108. SetIcon(m_hIcon, FALSE); // Set small icon
  109. CString strCommandLine(theApp.m_lpCmdLine);
  110. strCommandLine.MakeLower();
  111. // If we are being run with the auto command line (we're being automatically
  112. // run when the user boots) then we should display an informational dialog
  113. // (unless the user has indicated to not show the dialog).
  114. m_fShowInfoDialog = FALSE;
  115. if (strCommandLine.Find(COMMANDLINE_AUTO) != -1)
  116. {
  117. CMSConfigState * pState = m_ctl.GetState();
  118. if (pState)
  119. {
  120. CRegKey regkey;
  121. DWORD dwValue;
  122. regkey.Attach(pState->GetRegKey());
  123. if (ERROR_SUCCESS != regkey.QueryValue(dwValue, _T("HideAutoNotification")) || dwValue != 1)
  124. m_fShowInfoDialog = TRUE;
  125. }
  126. }
  127. // Initialize the CMSConfigCtl object which does most of the work for
  128. // this application.
  129. m_ctl.Initialize(this, IDC_BUTTONAPPLY, IDC_PLACEHOLDER, IDC_MSCONFIGTAB, strCommandLine);
  130. return TRUE; // return TRUE unless you set the focus to a control
  131. }
  132. void CMSConfigDlg::OnSysCommand(UINT nID, LPARAM lParam)
  133. {
  134. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  135. {
  136. CAboutDlg dlgAbout;
  137. dlgAbout.DoModal();
  138. }
  139. else
  140. {
  141. CDialog::OnSysCommand(nID, lParam);
  142. }
  143. }
  144. // If you add a minimize button to your dialog, you will need the code below
  145. // to draw the icon. For MFC applications using the document/view model,
  146. // this is automatically done for you by the framework.
  147. void CMSConfigDlg::OnPaint()
  148. {
  149. if (IsIconic())
  150. {
  151. CPaintDC dc(this); // device context for painting
  152. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  153. // Center icon in client rectangle
  154. int cxIcon = GetSystemMetrics(SM_CXICON);
  155. int cyIcon = GetSystemMetrics(SM_CYICON);
  156. CRect rect;
  157. GetClientRect(&rect);
  158. int x = (rect.Width() - cxIcon + 1) / 2;
  159. int y = (rect.Height() - cyIcon + 1) / 2;
  160. // Draw the icon
  161. dc.DrawIcon(x, y, m_hIcon);
  162. }
  163. else
  164. {
  165. CDialog::OnPaint();
  166. }
  167. if (m_fShowInfoDialog)
  168. {
  169. m_fShowInfoDialog = FALSE;
  170. CAutoStartDlg dlg;
  171. dlg.DoModal();
  172. if (dlg.m_checkDontShow)
  173. {
  174. CMSConfigState * pState = m_ctl.GetState();
  175. if (pState)
  176. {
  177. CRegKey regkey;
  178. regkey.Attach(pState->GetRegKey());
  179. regkey.SetValue(1, _T("HideAutoNotification"));
  180. }
  181. }
  182. }
  183. }
  184. // The system calls this to obtain the cursor to display while the user drags
  185. // the minimized window.
  186. HCURSOR CMSConfigDlg::OnQueryDragIcon()
  187. {
  188. return (HCURSOR) m_hIcon;
  189. }
  190. void CMSConfigDlg::OnButtonApply()
  191. {
  192. m_ctl.OnClickedButtonApply();
  193. }
  194. void CMSConfigDlg::OnButtonCancel()
  195. {
  196. m_ctl.OnClickedButtonCancel();
  197. EndDialog(0);
  198. }
  199. void CMSConfigDlg::OnButtonOK()
  200. {
  201. m_ctl.OnClickedButtonOK();
  202. EndDialog(0);
  203. }
  204. void CMSConfigDlg::OnSelChangeMSConfigTab(NMHDR* pNMHDR, LRESULT* pResult)
  205. {
  206. m_ctl.OnSelChangeMSConfigTab();
  207. *pResult = 0;
  208. }
  209. void CMSConfigDlg::OnSelChangingMSConfigTab(NMHDR* pNMHDR, LRESULT* pResult)
  210. {
  211. m_ctl.OnSelChangingMSConfigTab();
  212. *pResult = 0;
  213. }
  214. void CMSConfigDlg::OnClose()
  215. {
  216. OnButtonCancel();
  217. CDialog::OnClose();
  218. }
  219. BOOL CMSConfigDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  220. {
  221. TCHAR szHelpPath[MAX_PATH];
  222. if (::ExpandEnvironmentStrings(_T("%windir%\\help\\msconfig.chm"), szHelpPath, MAX_PATH))
  223. ::HtmlHelp(m_hWnd, szHelpPath, HH_DISPLAY_TOPIC, 0);
  224. return TRUE;
  225. }
  226. void CMSConfigDlg::OnButtonHelp()
  227. {
  228. OnHelpInfo(NULL);
  229. }