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.

148 lines
4.0 KiB

  1. #include "stdafx.h"
  2. #include "Msconfig.h"
  3. #include "MSConfigCtl.h"
  4. #include "pagebase.h"
  5. #include "pagegeneral.h"
  6. #include "pagebootini.h"
  7. #include "pageini.h"
  8. #include "pageservices.h"
  9. #include "pagestartup.h"
  10. #include <htmlhelp.h>
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CMSConfigSheet
  18. IMPLEMENT_DYNAMIC(CMSConfigSheet, CPropertySheet)
  19. CMSConfigSheet::CMSConfigSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage) : CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
  20. {
  21. m_iSelectedPage = iSelectPage;
  22. m_psh.dwFlags |= PSH_USEPAGELANG;
  23. }
  24. CMSConfigSheet::CMSConfigSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) : CPropertySheet(pszCaption, pParentWnd, iSelectPage)
  25. {
  26. m_iSelectedPage = iSelectPage;
  27. m_psh.dwFlags |= PSH_USEPAGELANG;
  28. }
  29. CMSConfigSheet::~CMSConfigSheet()
  30. {
  31. }
  32. BEGIN_MESSAGE_MAP(CMSConfigSheet, CPropertySheet)
  33. //{{AFX_MSG_MAP(CMSConfigSheet)
  34. ON_WM_HELPINFO()
  35. ON_COMMAND(ID_HELP, OnHelp)
  36. //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38. //-----------------------------------------------------------------------------
  39. // Catch the help messages to show the MSConfig help file.
  40. //-----------------------------------------------------------------------------
  41. BOOL CMSConfigSheet::OnHelpInfo(HELPINFO * pHelpInfo)
  42. {
  43. TCHAR szHelpPath[MAX_PATH];
  44. // Try to find a localized help file to open (bug 460691). It should be
  45. // located in %windir%\help\mui\<LANGID>.
  46. if (::ExpandEnvironmentStrings(_T("%SystemRoot%\\help\\mui"), szHelpPath, MAX_PATH))
  47. {
  48. CString strLanguageIDPath;
  49. LANGID langid = GetUserDefaultUILanguage();
  50. strLanguageIDPath.Format(_T("%s\\%04x\\msconfig.chm"), szHelpPath, langid);
  51. if (FileExists(strLanguageIDPath))
  52. {
  53. ::HtmlHelp(::GetDesktopWindow(), strLanguageIDPath, HH_DISPLAY_TOPIC, 0);
  54. return TRUE;
  55. }
  56. }
  57. if (::ExpandEnvironmentStrings(_T("%windir%\\help\\msconfig.chm"), szHelpPath, MAX_PATH))
  58. ::HtmlHelp(::GetDesktopWindow(), szHelpPath, HH_DISPLAY_TOPIC, 0);
  59. return TRUE;
  60. }
  61. void CMSConfigSheet::OnHelp()
  62. {
  63. OnHelpInfo(NULL);
  64. }
  65. //-----------------------------------------------------------------------------
  66. // Override this so we can make each page the active page, forcing each one's
  67. // OnInitDialog to be called.
  68. //-----------------------------------------------------------------------------
  69. extern CPageIni * ppageSystemIni;
  70. BOOL CMSConfigSheet::OnInitDialog()
  71. {
  72. CPropertySheet::OnInitDialog();
  73. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32.
  74. HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  75. SetIcon(hIcon, TRUE); // Set big icon
  76. SetIcon(hIcon, FALSE); // Set small icon
  77. // Change the caption of the system.ini tab.
  78. if (ppageSystemIni)
  79. {
  80. int nItem = GetPageIndex(ppageSystemIni);
  81. if (nItem > 0)
  82. {
  83. CTabCtrl * pTabs = GetTabControl();
  84. if (pTabs)
  85. {
  86. CString strCaption;
  87. strCaption.LoadString(IDS_SYSTEMINI_CAPTION);
  88. TCITEM tci;
  89. tci.mask = TCIF_TEXT;
  90. tci.pszText = (LPTSTR)(LPCTSTR)strCaption;
  91. pTabs->SetItem(nItem, &tci);
  92. }
  93. }
  94. }
  95. // Set each page active (before we make the dialog visible) to force
  96. // the WM_INITDIALOG message to be sent.
  97. for (int iPage = 0; iPage < GetPageCount(); iPage++)
  98. SetActivePage(iPage);
  99. SetActivePage(m_iSelectedPage);
  100. return TRUE; // return TRUE unless you set the focus to a control
  101. }
  102. //-----------------------------------------------------------------------------
  103. // Check to see if the specified file (with path information) exists on
  104. // the machine.
  105. //-----------------------------------------------------------------------------
  106. BOOL FileExists(const CString & strFile)
  107. {
  108. WIN32_FIND_DATA finddata;
  109. HANDLE h = FindFirstFile(strFile, &finddata);
  110. if (INVALID_HANDLE_VALUE != h)
  111. {
  112. FindClose(h);
  113. return TRUE;
  114. }
  115. return FALSE;
  116. }