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.

247 lines
6.5 KiB

  1. /****************************************************************************\
  2. OEMCUST.C
  3. Microsoft Confidential
  4. Copyright (c) Microsoft Corporation 1998
  5. All rights reserved
  6. Dialog proc and other stuff for the OEM custom file screen.
  7. 3/99 - Added by JCOHEN
  8. 09/2000 - Stephen Lodwick (STELO)
  9. Ported OPK Wizard to Whistler
  10. \****************************************************************************/
  11. //
  12. // Include File(s):
  13. //
  14. #include "pch.h"
  15. #ifdef OEMCUST
  16. #include "newfiles.h"
  17. #include "wizard.h"
  18. #include "resource.h"
  19. //
  20. // Internal Defined Value(s):
  21. //
  22. #define OEMCUST_FILE _T("OEMCUST.HTM")
  23. //
  24. // Internal Global Variable(s):
  25. //
  26. TCHAR g_szOemCustomDir[MAX_PATH];
  27. //
  28. // Internal Function Prototype(s):
  29. //
  30. static BOOL OnSetActive(HWND);
  31. static BOOL OnInit(HWND, HWND, LPARAM);
  32. static VOID OnCommand(HWND, INT, HWND, UINT);
  33. static BOOL OnNext(HWND);
  34. //
  35. // External Function(s):
  36. //
  37. BOOL CALLBACK OemCustDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  38. {
  39. switch (uMsg)
  40. {
  41. HANDLE_MSG(hwnd, WM_INITDIALOG, OnInit);
  42. HANDLE_MSG(hwnd, WM_COMMAND, OnCommand);
  43. case WM_NOTIFY:
  44. switch ( ((NMHDR FAR *) lParam)->code )
  45. {
  46. case PSN_KILLACTIVE:
  47. case PSN_RESET:
  48. case PSN_WIZBACK:
  49. case PSN_WIZFINISH:
  50. break;
  51. case PSN_WIZNEXT:
  52. if ( !OnNext(hwnd) )
  53. SetWindowLongPtr(hwnd, DWLP_MSGRESULT, -1);
  54. break;
  55. case PSN_QUERYCANCEL:
  56. WIZ_CANCEL(hwnd);
  57. break;
  58. case PSN_HELP:
  59. WIZ_HELP();
  60. break;
  61. case PSN_SETACTIVE:
  62. g_App.dwCurrentHelp = IDH_SANDBOX;
  63. if ( OnSetActive(hwnd) )
  64. PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_BACK | PSWIZB_NEXT);
  65. else
  66. SetWindowLongPtr(hwnd, DWLP_MSGRESULT, -1);
  67. break;
  68. default:
  69. return FALSE;
  70. }
  71. break;
  72. default:
  73. return FALSE;
  74. }
  75. return TRUE;
  76. }
  77. //
  78. // Internal Function(s):
  79. //
  80. static BOOL OnSetActive(HWND hwnd)
  81. {
  82. // If this page is OK to show, just return TRUE.
  83. //
  84. if ( GET_FLAG(OPK_OEM) )
  85. return TRUE;
  86. // This page and setting is not allowed in non OEM.
  87. //
  88. if ( IsDlgButtonChecked(hwnd, IDC_OEMCUST_ON) == BST_CHECKED )
  89. {
  90. // We have to make sure the check box is uncheck. They may
  91. // have already been to this page when multi-lingual wasn't set.
  92. //
  93. CheckDlgButton(hwnd, IDC_OEMCUST_ON, BST_UNCHECKED);
  94. EnableWindow(GetDlgItem(hwnd, IDC_OEMCUST_TEXT), FALSE);
  95. EnableWindow(GetDlgItem(hwnd, IDC_OEMCUST_DIR), FALSE);
  96. EnableWindow(GetDlgItem(hwnd, IDC_OEMCUST_BROWSE), FALSE);
  97. // Now save the unchecked state to the file.
  98. //
  99. OnNext(hwnd);
  100. }
  101. // We don't want to display this page.
  102. //
  103. return FALSE;
  104. }
  105. static BOOL OnInit(HWND hwnd, HWND hwndFocus, LPARAM lParam)
  106. {
  107. // Get the file path to use for the OEM custom files from
  108. // opkwiz inf.
  109. //
  110. GetPrivateProfileString(INI_SEC_OPTIONS, INI_KEY_OEMCUST, NULLSTR, g_szOemCustomDir, sizeof(g_szOemCustomDir) / sizeof (TCHAR), g_App.szOpkWizIniFile);
  111. SetDlgItemText(hwnd, IDC_OEMCUST_DIR, g_szOemCustomDir);
  112. // Check the dialog box if it was set in the oobeinfo ini.
  113. //
  114. if ( GetPrivateProfileInt(INI_SEC_OPTIONS, INI_KEY_OEMCUST, 0, g_App.szOobeInfoIniFile) )
  115. {
  116. CheckDlgButton(hwnd, IDC_OEMCUST_ON, BST_CHECKED);
  117. EnableWindow(GetDlgItem(hwnd, IDC_OEMCUST_TEXT), TRUE);
  118. EnableWindow(GetDlgItem(hwnd, IDC_OEMCUST_DIR), TRUE);
  119. EnableWindow(GetDlgItem(hwnd, IDC_OEMCUST_BROWSE), TRUE);
  120. }
  121. return FALSE;
  122. }
  123. static VOID OnCommand(HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify)
  124. {
  125. BOOL bCheck;
  126. switch ( id )
  127. {
  128. case IDC_OEMCUST_ON:
  129. // Enable/Disable the extra stuff if the option is checked or not.
  130. //
  131. bCheck = ( IsDlgButtonChecked(hwnd, IDC_OEMCUST_ON) == BST_CHECKED );
  132. EnableWindow(GetDlgItem(hwnd, IDC_OEMCUST_TEXT), bCheck);
  133. EnableWindow(GetDlgItem(hwnd, IDC_OEMCUST_DIR), bCheck);
  134. EnableWindow(GetDlgItem(hwnd, IDC_OEMCUST_BROWSE), bCheck);
  135. break;
  136. case IDC_OEMCUST_BROWSE:
  137. // Browse for the folder the OEM wants to use as their source.
  138. //
  139. if ( BrowseForFolder(hwnd, IDS_BROWSEFOLDER, g_szOemCustomDir) )
  140. SetDlgItemText(hwnd, IDC_OEMCUST_DIR, g_szOemCustomDir);
  141. break;
  142. }
  143. }
  144. static BOOL OnNext(HWND hwnd)
  145. {
  146. TCHAR szFullPath[MAX_PATH];
  147. BOOL bCheck;
  148. DWORD dwAttr;
  149. //
  150. // First do some checks to make sure we can continue.
  151. //
  152. // If we have custom OEM files, there are some checks to make.
  153. //
  154. GetDlgItemText(hwnd, IDC_OEMCUST_DIR, g_szOemCustomDir, sizeof(g_szOemCustomDir));
  155. if ( bCheck = ( IsDlgButtonChecked(hwnd, IDC_OEMCUST_ON) == BST_CHECKED ) )
  156. {
  157. // Make sure we have a valid directory.
  158. //
  159. if ( g_szOemCustomDir[0] )
  160. dwAttr = GetFileAttributes(g_szOemCustomDir);
  161. if ( ( !g_szOemCustomDir[0] ) ||
  162. ( dwAttr == 0xFFFFFFFF ) ||
  163. ( !( dwAttr & FILE_ATTRIBUTE_DIRECTORY ) ) )
  164. {
  165. MsgBox(GetParent(hwnd), IDS_ERR_OEMCUSTDIR, IDS_APPNAME, MB_ERRORBOX);
  166. SetFocus(GetDlgItem(hwnd, IDC_OEMCUST_DIR));
  167. return FALSE;
  168. }
  169. // Check for hardware tutorial required file.
  170. //
  171. lstrcpyn(szFullPath, g_szOemCustomDir,AS(szFullPath));
  172. AddPathN(szFullPath, OEMCUST_FILE,AS(szFullPath));
  173. if ( ( !EXIST(szFullPath) ) && ( MsgBox(GetParent(hwnd), IDS_ERR_OEMCUSTFILE, IDS_APPNAME, MB_ICONSTOP | MB_OKCANCEL | MB_APPLMODAL) == IDCANCEL ) )
  174. return FALSE;
  175. }
  176. //
  177. // Checks are done, save the data now.
  178. //
  179. // Save the file path to use for the OEM custom files
  180. // in opkwiz inf.
  181. //
  182. WritePrivateProfileString(INI_SEC_OPTIONS, INI_KEY_OEMCUST, g_szOemCustomDir, g_App.szOpkWizIniFile);
  183. // Save the on/off setting for the OEM custom files
  184. // in oobeinfo ini.
  185. //
  186. WritePrivateProfileString(INI_SEC_OPTIONS, INI_KEY_OEMCUST, bCheck ? _T("1") : NULL, g_App.szOobeInfoIniFile);
  187. return TRUE;
  188. }
  189. #endif // OEMCUST