Source code of Windows XP (NT5)
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.

131 lines
3.3 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. if (::ExpandEnvironmentStrings(_T("%windir%\\help\\msconfig.chm"), szHelpPath, MAX_PATH))
  45. ::HtmlHelp(::GetDesktopWindow(), szHelpPath, HH_DISPLAY_TOPIC, 0);
  46. return TRUE;
  47. }
  48. void CMSConfigSheet::OnHelp()
  49. {
  50. OnHelpInfo(NULL);
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Override this so we can make each page the active page, forcing each one's
  54. // OnInitDialog to be called.
  55. //-----------------------------------------------------------------------------
  56. extern CPageIni * ppageSystemIni;
  57. BOOL CMSConfigSheet::OnInitDialog()
  58. {
  59. CPropertySheet::OnInitDialog();
  60. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32.
  61. HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  62. SetIcon(hIcon, TRUE); // Set big icon
  63. SetIcon(hIcon, FALSE); // Set small icon
  64. // Change the caption of the system.ini tab.
  65. if (ppageSystemIni)
  66. {
  67. int nItem = GetPageIndex(ppageSystemIni);
  68. if (nItem > 0)
  69. {
  70. CTabCtrl * pTabs = GetTabControl();
  71. if (pTabs)
  72. {
  73. CString strCaption;
  74. strCaption.LoadString(IDS_SYSTEMINI_CAPTION);
  75. TCITEM tci;
  76. tci.mask = TCIF_TEXT;
  77. tci.pszText = (LPTSTR)(LPCTSTR)strCaption;
  78. pTabs->SetItem(nItem, &tci);
  79. }
  80. }
  81. }
  82. // Set each page active (before we make the dialog visible) to force
  83. // the WM_INITDIALOG message to be sent.
  84. for (int iPage = 0; iPage < GetPageCount(); iPage++)
  85. SetActivePage(iPage);
  86. SetActivePage(m_iSelectedPage);
  87. return TRUE; // return TRUE unless you set the focus to a control
  88. }
  89. //-----------------------------------------------------------------------------
  90. // Check to see if the specified file (with path information) exists on
  91. // the machine.
  92. //-----------------------------------------------------------------------------
  93. BOOL FileExists(const CString & strFile)
  94. {
  95. WIN32_FIND_DATA finddata;
  96. HANDLE h = FindFirstFile(strFile, &finddata);
  97. if (INVALID_HANDLE_VALUE != h)
  98. {
  99. FindClose(h);
  100. return TRUE;
  101. }
  102. return FALSE;
  103. }