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.

322 lines
8.6 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. // All rights reserved.
  5. //
  6. // File Name:
  7. // maindlgs.c
  8. //
  9. // Description:
  10. // This file has dialog procedures for welcome and finish pages.
  11. //
  12. //----------------------------------------------------------------------------
  13. #include "pch.h"
  14. #include "resource.h"
  15. //----------------------------------------------------------------------------
  16. //
  17. // Function: OnWelcomeInitDialog
  18. //
  19. // Purpose:
  20. //
  21. // Arguments: IN HWND hwnd - handle to the dialog box
  22. //
  23. // Returns: VOID
  24. //
  25. //----------------------------------------------------------------------------
  26. VOID
  27. OnWelcomeInitDialog( IN HWND hwnd ) {
  28. LPWSTR szCommandLineArguments;
  29. INT argc;
  30. LPWSTR *argv;
  31. RECT rc;
  32. LPTSTR lpWelcomeText = NULL;
  33. SetWindowFont( GetDlgItem(hwnd, IDC_BIGBOLDTITLE),
  34. FixedGlobals.hBigBoldFont,
  35. TRUE );
  36. // Set the welcome text
  37. //
  38. if (lpWelcomeText = AllocateString(NULL, IDS_WELCOME_TEXT_CORP))
  39. {
  40. SetDlgItemText(hwnd, IDC_WELCOME_TEXT, lpWelcomeText);
  41. FREE(lpWelcomeText);
  42. }
  43. FixedGlobals.ScriptName[0] = _T('\0');
  44. szCommandLineArguments = GetCommandLine();
  45. argv = CommandLineToArgvW( szCommandLineArguments, &argc );
  46. if( argv == NULL ) {
  47. //
  48. // If I can't get the command line, then do nothing
  49. //
  50. return;
  51. }
  52. //
  53. // If they passed an answerfile on the command line, then jump to the
  54. // load wizard page
  55. //
  56. if( argc > 1 ) {
  57. lstrcpyn( FixedGlobals.ScriptName, argv[1], AS(FixedGlobals.ScriptName) );
  58. PostMessage( GetParent( hwnd ),
  59. PSM_SETCURSELID,
  60. (WPARAM) 0,
  61. (LPARAM) IDD_NEWOREDIT );
  62. }
  63. // Center the wizard.
  64. //
  65. if ( GetWindowRect(GetParent(hwnd), &rc) )
  66. SetWindowPos(GetParent(hwnd), NULL, ((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2), ((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2), 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
  67. }
  68. //----------------------------------------------------------------------------
  69. //
  70. // Function: DlgWelcomePage
  71. //
  72. // Purpose: Dialog procedure for the welcome page.
  73. //
  74. //----------------------------------------------------------------------------
  75. INT_PTR CALLBACK DlgWelcomePage(
  76. IN HWND hwnd,
  77. IN UINT uMsg,
  78. IN WPARAM wParam,
  79. IN LPARAM lParam)
  80. {
  81. BOOL bStatus = TRUE;
  82. switch (uMsg) {
  83. case WM_INITDIALOG:
  84. // Not sure how to enable this on corp mode w/o the setupmgr.ini file,
  85. // so just don't give the option for now.
  86. //
  87. ShowWindow(GetDlgItem(hwnd, IDC_HIDE), SW_HIDE);
  88. if ( GET_FLAG(OPK_WELCOME) )
  89. WIZ_PRESS(hwnd, PSBTN_NEXT);
  90. else
  91. {
  92. SET_FLAG(OPK_WELCOME, TRUE);
  93. OnWelcomeInitDialog( hwnd );
  94. }
  95. break;
  96. case WM_NOTIFY:
  97. {
  98. LPNMHDR pnmh = (LPNMHDR)lParam;
  99. switch( pnmh->code ) {
  100. case PSN_QUERYCANCEL:
  101. WIZ_CANCEL(hwnd);
  102. break;
  103. case PSN_SETACTIVE:
  104. WIZ_BUTTONS(hwnd, PSWIZB_NEXT);
  105. break;
  106. case PSN_WIZNEXT:
  107. bStatus = FALSE;
  108. break;
  109. default:
  110. bStatus = FALSE;
  111. break;
  112. }
  113. }
  114. break;
  115. default:
  116. bStatus = FALSE;
  117. break;
  118. }
  119. return bStatus;
  120. }
  121. #define NTEXTFIELDS 3
  122. VOID
  123. OnInitFinishPage(IN HWND hwnd)
  124. {
  125. TCHAR *FileNames[NTEXTFIELDS], *p;
  126. int i,j;
  127. SetWindowFont(GetDlgItem(hwnd, IDC_BIGBOLDTITLE),
  128. FixedGlobals.hBigBoldFont,
  129. TRUE);
  130. //
  131. // Put the filenames we want to display into an array and squish out
  132. // the null strings
  133. //
  134. FileNames[0] = FixedGlobals.ScriptName;
  135. FileNames[1] = FixedGlobals.UdfFileName;
  136. FileNames[2] = FixedGlobals.BatchFileName;
  137. for ( i=0; i<NTEXTFIELDS; i++ ) {
  138. if ( FileNames[i] == NULL || FileNames[i][0] == _T('\0') ) {
  139. for ( j=i; j<NTEXTFIELDS-1; j++ ) {
  140. FileNames[j] = FileNames[j+1];
  141. }
  142. FileNames[j] = NULL;
  143. }
  144. }
  145. SetDlgItemText( hwnd, IDC_FILENAME1, (p = FileNames[0]) ? p : _T("") );
  146. SetDlgItemText( hwnd, IDC_FILENAME2, (p = FileNames[1]) ? p : _T("") );
  147. SetDlgItemText( hwnd, IDC_FILENAME3, (p = FileNames[2]) ? p : _T("") );
  148. // Show the batch example message if we have a batch file
  149. //
  150. ShowWindow(GetDlgItem(hwnd, IDC_BATCHTEXT), FixedGlobals.BatchFileName[0] ? SW_SHOW : SW_HIDE);
  151. //
  152. // ISSUE-2002/02/28-stelo- In the case of remote boot, we need to change the text
  153. // message at the bottom of this page about the batch script
  154. // Need to tell them to use the ris admin tool to enable
  155. // the answer file.
  156. //
  157. PropSheet_SetWizButtons(GetParent(hwnd), PSWIZB_FINISH);
  158. }
  159. //----------------------------------------------------------------------------
  160. //
  161. // Function: DlgFinishPage
  162. //
  163. // Purpose: Dialog procedure for the finish page.
  164. //
  165. //----------------------------------------------------------------------------
  166. INT_PTR CALLBACK DlgFinishPage(
  167. IN HWND hwnd,
  168. IN UINT uMsg,
  169. IN WPARAM wParam,
  170. IN LPARAM lParam)
  171. {
  172. BOOL bStatus = TRUE;
  173. switch (uMsg) {
  174. case WM_INITDIALOG:
  175. OnInitFinishPage(hwnd);
  176. break;
  177. case WM_NOTIFY:
  178. {
  179. LPNMHDR pnmh = (LPNMHDR)lParam;
  180. switch( pnmh->code ) {
  181. //
  182. // ISSUE-2002/02/28-stelo- A cancel button on the successful completion
  183. // page doesn't make alot of sense either.
  184. // What do other good wizards do???
  185. //
  186. case PSN_QUERYCANCEL:
  187. CancelTheWizard(hwnd);
  188. break;
  189. case PSN_SETACTIVE:
  190. break;
  191. case PSN_WIZBACK:
  192. break;
  193. case PSN_WIZFINISH:
  194. break;
  195. default:
  196. bStatus = FALSE;
  197. break;
  198. }
  199. }
  200. break;
  201. default:
  202. bStatus = FALSE;
  203. break;
  204. }
  205. return bStatus;
  206. }
  207. //----------------------------------------------------------------------------
  208. //
  209. // Function: DlgFinish2Page
  210. //
  211. // Purpose: Unsuccessful completion page
  212. //
  213. //----------------------------------------------------------------------------
  214. INT_PTR CALLBACK DlgFinish2Page(
  215. IN HWND hwnd,
  216. IN UINT uMsg,
  217. IN WPARAM wParam,
  218. IN LPARAM lParam)
  219. {
  220. BOOL bStatus = TRUE;
  221. switch (uMsg) {
  222. case WM_INITDIALOG:
  223. SetWindowFont(GetDlgItem(hwnd, IDC_BIGBOLDTITLE),
  224. FixedGlobals.hBigBoldFont,
  225. TRUE);
  226. break;
  227. case WM_NOTIFY:
  228. {
  229. LPNMHDR pnmh = (LPNMHDR)lParam;
  230. switch( pnmh->code ) {
  231. //
  232. // ISSUE-2002/02/28-stelo- What is the proper thing to do here?
  233. // Disable the cancel button?
  234. // Find out what other wizards do on the
  235. // unsuccessful completion page.
  236. //
  237. case PSN_QUERYCANCEL:
  238. break;
  239. case PSN_SETACTIVE:
  240. PropSheet_SetWizButtons(
  241. GetParent(hwnd),
  242. PSWIZB_FINISH );
  243. break;
  244. case PSN_WIZFINISH:
  245. break;
  246. default:
  247. bStatus = FALSE;
  248. break;
  249. }
  250. }
  251. break;
  252. default:
  253. bStatus = FALSE;
  254. break;
  255. }
  256. return bStatus;
  257. }