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.

507 lines
12 KiB

  1. //+------------------------------------------------------------------
  2. //
  3. // Project: Windows NT4 DS Client Setup Wizard
  4. //
  5. // Purpose: Installs the Windows NT4 DS Client Files
  6. //
  7. // File: wizard.cpp
  8. //
  9. // History: March 1998 Zeyong Xu Created
  10. // Jan 2000 Jeff Jones (JeffJon) Modified
  11. // - changed to be an NT setup
  12. //
  13. //------------------------------------------------------------------
  14. #include <windows.h>
  15. #include <windowsx.h>
  16. #include <prsht.h>
  17. #include "resource.h"
  18. #include "dscsetup.h"
  19. #include "doinst.h"
  20. #include "wizard.h"
  21. extern SInstallVariables g_sInstVar;
  22. // welcome page DlgProc of wizard
  23. BOOL CALLBACK WelcomeDialogProc(HWND hWnd,
  24. UINT nMessage,
  25. WPARAM wParam,
  26. LPARAM lParam)
  27. {
  28. BOOL bReturn = FALSE;
  29. LPNMHDR lpNotifyMsg;
  30. switch (nMessage)
  31. {
  32. case WM_INITDIALOG:
  33. {
  34. RECT rc;
  35. // set font of title text
  36. SetWindowFont(GetDlgItem(hWnd, IDC_STATIC_WELCOME_TITLE),
  37. g_sInstVar.m_hBigBoldFont,
  38. TRUE);
  39. // Position the dialog
  40. if (GetWindowRect(GetParent(hWnd), &rc))
  41. {
  42. SetWindowPos(GetParent(hWnd),
  43. HWND_TOP,
  44. (GetSystemMetrics(SM_CXSCREEN) / 2) -
  45. ((rc.right - rc.left) / 2),
  46. (GetSystemMetrics(SM_CYSCREEN) / 2) -
  47. ((rc.bottom - rc.top) / 2),
  48. rc.right - rc.left,
  49. rc.bottom - rc.top,
  50. SWP_NOOWNERZORDER);
  51. }
  52. break;
  53. }
  54. case WM_NOTIFY:
  55. lpNotifyMsg = (NMHDR FAR*) lParam;
  56. switch (lpNotifyMsg->code)
  57. {
  58. // user click cancel
  59. case PSN_QUERYCANCEL:
  60. // cancel confirm?
  61. if(!ConfirmCancelWizard(hWnd))
  62. {
  63. SetWindowLongPtr(hWnd, DWL_MSGRESULT, TRUE);
  64. bReturn = TRUE;
  65. }
  66. break;
  67. case PSN_WIZNEXT:
  68. break;
  69. case PSN_SETACTIVE:
  70. PropSheet_SetWizButtons(GetParent(hWnd), PSWIZB_NEXT);
  71. break;
  72. default:
  73. break;
  74. }
  75. break;
  76. default:
  77. break;
  78. }
  79. return bReturn;
  80. }
  81. /* ntbug#337931: remove license page
  82. // License page DlgProc of wizard
  83. BOOL CALLBACK LicenseDialogProc(HWND hWnd,
  84. UINT nMessage,
  85. WPARAM wParam,
  86. LPARAM lParam)
  87. {
  88. BOOL bReturn = FALSE;
  89. LPNMHDR lpNotifyMsg;
  90. HFONT hLicenseTextFont;
  91. switch (nMessage)
  92. {
  93. case WM_INITDIALOG:
  94. if(!CheckDiskSpace() || // check disk space
  95. !LoadLicenseFile(hWnd)) // Load license file
  96. {
  97. g_sInstVar.m_nSetupResult = SETUP_ERROR;
  98. PropSheet_PressButton(GetParent(hWnd), PSBTN_FINISH); // close wizard
  99. }
  100. // use a ANSI_FIXED_FONT (Couirer) font for EULA to replace the default
  101. // font - MS Shell Dlg in order to fix the bug in Hebrew Win95
  102. if(g_sInstVar.m_bWin95)
  103. {
  104. hLicenseTextFont = (HFONT) GetStockObject(ANSI_FIXED_FONT);
  105. if(hLicenseTextFont)
  106. {
  107. SetWindowFont(GetDlgItem(hWnd, IDC_LICENSE_TEXT),
  108. hLicenseTextFont,
  109. TRUE);
  110. }
  111. }
  112. bReturn = TRUE;
  113. break;
  114. case WM_NOTIFY:
  115. lpNotifyMsg = (NMHDR FAR*) lParam;
  116. switch (lpNotifyMsg->code)
  117. {
  118. // user click cancel
  119. case PSN_QUERYCANCEL:
  120. // cancel confirm?
  121. if(!ConfirmCancelWizard(hWnd))
  122. {
  123. SetWindowLongPtr(hWnd, DWL_MSGRESULT, TRUE);
  124. bReturn = TRUE;
  125. }
  126. break;
  127. case PSN_WIZNEXT:
  128. break;
  129. case PSN_SETACTIVE:
  130. {
  131. HWND hButton;
  132. hButton = GetDlgItem(hWnd, IDC_RADIO_ACCEPTED);
  133. // get radio button check status
  134. if( hButton &&
  135. BST_CHECKED == SendMessage(hButton, BM_GETCHECK, 0, 0L) )
  136. PropSheet_SetWizButtons(GetParent(hWnd),
  137. PSWIZB_BACK | PSWIZB_NEXT);
  138. else
  139. PropSheet_SetWizButtons(GetParent(hWnd),
  140. PSWIZB_BACK);
  141. break;
  142. }
  143. default:
  144. break;
  145. }
  146. break;
  147. case WM_COMMAND: // button click
  148. {
  149. HWND hButton;
  150. hButton = GetDlgItem(hWnd, IDC_RADIO_ACCEPTED);
  151. // get radio button check status
  152. if( hButton && BST_CHECKED ==
  153. SendMessage(hButton, BM_GETCHECK, 0, 0L) )
  154. PropSheet_SetWizButtons(GetParent(hWnd),
  155. PSWIZB_BACK | PSWIZB_NEXT);
  156. else
  157. PropSheet_SetWizButtons(GetParent(hWnd),
  158. PSWIZB_BACK);
  159. }
  160. default:
  161. break;
  162. }
  163. return bReturn;
  164. }
  165. */
  166. // Confirm page DlgProc of wizard
  167. BOOL CALLBACK ConfirmDialogProc(HWND hWnd,
  168. UINT nMessage,
  169. WPARAM wParam,
  170. LPARAM lParam)
  171. {
  172. BOOL bReturn = FALSE;
  173. LPNMHDR lpNotifyMsg;
  174. switch (nMessage)
  175. {
  176. case WM_INITDIALOG:
  177. if(!CheckDiskSpace()) // check disk space
  178. {
  179. g_sInstVar.m_nSetupResult = SETUP_ERROR;
  180. PropSheet_PressButton(GetParent(hWnd), PSBTN_FINISH); // close wizard
  181. }
  182. // check if DSClient has been installed
  183. if(CheckDSClientInstalled())
  184. {
  185. // load string and dispaly it in textitem
  186. TCHAR szMessage[MAX_MESSAGE + 1];
  187. LoadString(g_sInstVar.m_hInstance,
  188. IDS_REINSTALL_MSG,
  189. szMessage,
  190. MAX_MESSAGE);
  191. SetDlgItemText(hWnd,
  192. IDC_STATIC_CONFIRM_INSTALL,
  193. szMessage);
  194. }
  195. break;
  196. case WM_NOTIFY:
  197. lpNotifyMsg = (NMHDR FAR*) lParam;
  198. switch (lpNotifyMsg->code)
  199. {
  200. // user click cancel
  201. case PSN_QUERYCANCEL:
  202. // cancel confirm?
  203. if(!ConfirmCancelWizard(hWnd))
  204. {
  205. SetWindowLongPtr(hWnd, DWL_MSGRESULT, TRUE);
  206. bReturn = TRUE;
  207. }
  208. break;
  209. case PSN_WIZNEXT:
  210. break;
  211. case PSN_SETACTIVE:
  212. PropSheet_SetWizButtons(GetParent(hWnd),
  213. PSWIZB_BACK | PSWIZB_NEXT);
  214. break;
  215. default:
  216. break;
  217. }
  218. break;
  219. default:
  220. break;
  221. }
  222. return bReturn;
  223. }
  224. // wizard dialog callback function
  225. BOOL CALLBACK InstallDialogProc(HWND hWnd,
  226. UINT nMessage,
  227. WPARAM wParam,
  228. LPARAM lParam)
  229. {
  230. BOOL bReturn = FALSE;
  231. LPNMHDR lpMsg;
  232. switch (nMessage)
  233. {
  234. case WM_INITDIALOG:
  235. {
  236. DWORD dwThreadId;
  237. // get the handle of install progress bar and file name item
  238. g_sInstVar.m_hProgress = GetDlgItem(hWnd, IDC_INSTALL_PROGRESS);
  239. g_sInstVar.m_hFileNameItem = GetDlgItem(hWnd, IDC_STATIC_FILENAME);
  240. // start to do installation
  241. g_sInstVar.m_hInstallThread = CreateThread(NULL,
  242. 0,
  243. DoInstallationProc,
  244. hWnd,
  245. 0,
  246. &dwThreadId);
  247. // if CreateThread() failed
  248. if(!g_sInstVar.m_hInstallThread)
  249. {
  250. g_sInstVar.m_nSetupResult = SETUP_ERROR;
  251. PropSheet_PressButton(GetParent(hWnd), PSBTN_FINISH); // close wizard
  252. }
  253. bReturn = TRUE;
  254. break;
  255. }
  256. case WM_NOTIFY:
  257. {
  258. lpMsg = (NMHDR FAR*) lParam;
  259. switch(lpMsg->code)
  260. {
  261. // cancel to do nothing
  262. case PSN_QUERYCANCEL:
  263. // block
  264. // REVIEWED-2002/03/12-JeffJon-We want to allow the exception
  265. // to propogate out
  266. EnterCriticalSection(&g_sInstVar.m_oCriticalSection);
  267. // cancel confirm?
  268. if(!ConfirmCancelWizard(hWnd))
  269. {
  270. SetWindowLongPtr(hWnd, DWL_MSGRESULT, TRUE);
  271. bReturn = TRUE;
  272. }
  273. // unblock
  274. LeaveCriticalSection(&g_sInstVar.m_oCriticalSection);
  275. break;
  276. case PSN_WIZFINISH:
  277. break;
  278. case PSN_WIZBACK:
  279. break;
  280. case PSN_SETACTIVE:
  281. PropSheet_SetWizButtons(GetParent(hWnd), 0);
  282. break;
  283. default:
  284. break;
  285. }
  286. }
  287. default:
  288. break;
  289. }
  290. return bReturn;
  291. }
  292. // Completion page DlgProc of wizard
  293. BOOL CALLBACK CompletionDialogProc(HWND hWnd,
  294. UINT nMessage,
  295. WPARAM wParam,
  296. LPARAM lParam)
  297. {
  298. BOOL bReturn = FALSE;
  299. LPNMHDR lpNotifyMsg;
  300. switch (nMessage)
  301. {
  302. case WM_INITDIALOG:
  303. {
  304. TCHAR szMessage[MAX_MESSAGE + 1];
  305. RECT rc;
  306. // load string and dispaly it in textitem
  307. switch (g_sInstVar.m_nSetupResult)
  308. {
  309. case SETUP_SUCCESS:
  310. LoadString(g_sInstVar.m_hInstance,
  311. IDS_SETUP_SUCCESS_TITLE,
  312. szMessage,
  313. MAX_MESSAGE);
  314. SetDlgItemText(hWnd, IDC_STATIC_COMPLETION_TITLE, szMessage);
  315. LoadString(g_sInstVar.m_hInstance,
  316. IDS_SETUP_SUCCESS,
  317. szMessage,
  318. MAX_MESSAGE);
  319. SetDlgItemText(hWnd, IDC_STATIC_COMPLETION, szMessage);
  320. break;
  321. case SETUP_CANCEL:
  322. LoadString(g_sInstVar.m_hInstance,
  323. IDS_SETUP_CANCEL_TITLE,
  324. szMessage,
  325. MAX_MESSAGE);
  326. SetDlgItemText(hWnd, IDC_STATIC_COMPLETION_TITLE, szMessage);
  327. LoadString(g_sInstVar.m_hInstance,
  328. IDS_SETUP_CANCEL,
  329. szMessage,
  330. MAX_MESSAGE);
  331. SetDlgItemText(hWnd, IDC_STATIC_COMPLETION, szMessage);
  332. break;
  333. case SETUP_ERROR:
  334. LoadString(g_sInstVar.m_hInstance,
  335. IDS_SETUP_ERROR_TITLE,
  336. szMessage,
  337. MAX_MESSAGE);
  338. SetDlgItemText(hWnd, IDC_STATIC_COMPLETION_TITLE, szMessage);
  339. LoadString(g_sInstVar.m_hInstance,
  340. IDS_SETUP_ERROR,
  341. szMessage,
  342. MAX_MESSAGE);
  343. SetDlgItemText(hWnd, IDC_STATIC_COMPLETION, szMessage);
  344. break;
  345. default:
  346. break;
  347. }
  348. // set font of title text
  349. SetWindowFont(GetDlgItem(hWnd, IDC_STATIC_COMPLETION_TITLE),
  350. g_sInstVar.m_hBigBoldFont,
  351. TRUE);
  352. // Position the dialog
  353. if (GetWindowRect(GetParent(hWnd), &rc))
  354. {
  355. SetWindowPos(GetParent(hWnd),
  356. HWND_TOP,
  357. (GetSystemMetrics(SM_CXSCREEN) / 2) -
  358. ((rc.right - rc.left) / 2),
  359. (GetSystemMetrics(SM_CYSCREEN) / 2) -
  360. ((rc.bottom - rc.top) / 2),
  361. rc.right - rc.left,
  362. rc.bottom - rc.top,
  363. SWP_NOOWNERZORDER);
  364. }
  365. break;
  366. }
  367. case WM_NOTIFY:
  368. lpNotifyMsg = (NMHDR FAR*) lParam;
  369. switch (lpNotifyMsg->code)
  370. {
  371. case PSN_QUERYCANCEL:
  372. break;
  373. case PSN_WIZFINISH:
  374. break;
  375. case PSN_SETACTIVE:
  376. // set wizard button
  377. PropSheet_SetWizButtons(GetParent(hWnd), PSWIZB_FINISH);
  378. PropSheet_CancelToClose(GetParent(hWnd));
  379. break;
  380. default:
  381. break;
  382. }
  383. break;
  384. default:
  385. break;
  386. }
  387. return bReturn;
  388. }
  389. // ask if you want to cancel the wizard
  390. BOOL ConfirmCancelWizard(HWND hWnd)
  391. {
  392. TCHAR szMsg[MAX_MESSAGE + 1];
  393. TCHAR szTitle[MAX_TITLE + 1];
  394. LoadString(g_sInstVar.m_hInstance, IDS_CANCEL_TITLE, szTitle, MAX_TITLE);
  395. LoadString(g_sInstVar.m_hInstance, IDS_CANCEL_MSG, szMsg, MAX_MESSAGE);
  396. if (IDYES == MessageBox(hWnd,
  397. szMsg,
  398. szTitle,
  399. MB_YESNO | MB_TOPMOST | MB_ICONQUESTION))
  400. {
  401. // kill timer
  402. if(g_sInstVar.m_uTimerID)
  403. KillTimer(hWnd, g_sInstVar.m_uTimerID);
  404. // set m_nSetupResult to SETUP_CANCEL, in order to stop the inatllation
  405. g_sInstVar.m_nSetupResult = SETUP_CANCEL;
  406. return TRUE;
  407. }
  408. return FALSE;
  409. }
  410. // do installation proc
  411. DWORD WINAPI DoInstallationProc(LPVOID lpVoid)
  412. {
  413. HWND hWnd = (HWND)lpVoid;
  414. // do installation
  415. g_sInstVar.m_nSetupResult = DoInstallation(hWnd);
  416. // Close install page of the setup wizard
  417. PropSheet_PressButton(GetParent(hWnd), PSBTN_FINISH);
  418. return g_sInstVar.m_nSetupResult;
  419. }