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.

312 lines
6.6 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. Setup.cpp
  5. Abstract:
  6. Displays the splash screen and runs the message loop
  7. for the setup app.
  8. Notes:
  9. ANSI only - must run on Win9x.
  10. History:
  11. 01/30/01 rparsons Created
  12. 01/10/02 rparsons Revised
  13. --*/
  14. #include "demoapp.h"
  15. extern APPINFO g_ai;
  16. /*++
  17. Routine Description:
  18. Thread callback procedure.
  19. Arguments:
  20. None.
  21. Return Value:
  22. 0 on failure.
  23. --*/
  24. UINT
  25. InitSetupThread(
  26. IN void* pArguments
  27. )
  28. {
  29. MSG msg;
  30. CSplash splash;
  31. HWND hDlg;
  32. HINSTANCE hInstance;
  33. HRESULT hr;
  34. char szError[MAX_PATH];
  35. char szDll[MAX_PATH];
  36. const char szDemoDll[] = "demodll.dll";
  37. hr = StringCchPrintf(szDll,
  38. sizeof(szDll),
  39. "%hs\\%hs",
  40. g_ai.szCurrentDir,
  41. szDemoDll);
  42. if (FAILED(hr)) {
  43. return 0;
  44. }
  45. //
  46. // If the load fails, keep going. This just means we won't
  47. // show a splash screen to the user.
  48. //
  49. hInstance = LoadLibrary(szDll);
  50. if (g_ai.fWinXP) {
  51. //
  52. // Display the XP splash screen.
  53. //
  54. splash.Create(hInstance,
  55. IDB_XP_SPLASH_256,
  56. IDB_XP_SPLASH,
  57. 5);
  58. } else {
  59. //
  60. // Display the W2K splash screen.
  61. //
  62. splash.Create(hInstance,
  63. IDB_W2K_SPLASH_256,
  64. IDB_W2K_SPLASH,
  65. 5);
  66. }
  67. if (hInstance) {
  68. FreeLibrary(hInstance);
  69. }
  70. hDlg = CreateExtractionDialog(g_ai.hInstance);
  71. if (!hDlg) {
  72. LoadString(g_ai.hInstance, IDS_NO_EXTRACT_DLG, szError, sizeof(szError));
  73. MessageBox(NULL, szError, 0, MB_ICONERROR);
  74. return 0;
  75. }
  76. while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
  77. if (!IsDialogMessage(hDlg, &msg)) {
  78. TranslateMessage(&msg);
  79. DispatchMessage(&msg);
  80. }
  81. }
  82. _endthreadex(0);
  83. return (int)msg.wParam;
  84. }
  85. /*++
  86. Routine Description:
  87. Creates our full screen window.
  88. Arguments:
  89. None.
  90. Return Value:
  91. The window handle on success, NULL on failure.
  92. --*/
  93. HWND
  94. CreateFullScreenWindow(
  95. void
  96. )
  97. {
  98. WNDCLASS wc;
  99. ATOM aClass = NULL;
  100. RECT rcDesktop;
  101. HBRUSH hBrush;
  102. hBrush = CreateSolidBrush(RGB(0,80,80));
  103. wc.style = CS_NOCLOSE;
  104. wc.lpfnWndProc = SetupWndProc;
  105. wc.cbClsExtra = 0;
  106. wc.cbWndExtra = 0;
  107. wc.hInstance = g_ai.hInstance;
  108. wc.hIcon = LoadIcon(g_ai.hInstance, MAKEINTRESOURCE(IDI_SETUP_APPICON));
  109. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  110. wc.hbrBackground = (HBRUSH)hBrush; // teal
  111. wc.lpszMenuName = NULL;
  112. wc.lpszClassName = SETUP_APP_CLASS;
  113. aClass = RegisterClass(&wc);
  114. if (!aClass) {
  115. goto exit;
  116. }
  117. GetWindowRect(GetDesktopWindow(), &rcDesktop);
  118. g_ai.hWndMain = CreateWindowEx(0,
  119. SETUP_APP_CLASS,
  120. SETUP_APP_TITLE,
  121. WS_OVERLAPPEDWINDOW,
  122. 0,
  123. 0,
  124. rcDesktop.right - 15,
  125. rcDesktop.bottom - 15,
  126. NULL,
  127. NULL,
  128. g_ai.hInstance,
  129. NULL);
  130. exit:
  131. DeleteObject(hBrush);
  132. return g_ai.hWndMain;
  133. }
  134. /*++
  135. Routine Description:
  136. Runs the message loop for main window.
  137. Arguments:
  138. hWnd - Window handle.
  139. uMsg - Windows message.
  140. wParam - Additional message info.
  141. lParam - Additional message info.
  142. Return Value:
  143. TRUE if the message was processed, FALSE otherwise.
  144. --*/
  145. LRESULT
  146. CALLBACK
  147. SetupWndProc(
  148. IN HWND hWnd,
  149. IN UINT uMsg,
  150. IN WPARAM wParam,
  151. IN LPARAM lParam
  152. )
  153. {
  154. switch (uMsg) {
  155. case WM_CREATE:
  156. ShowWindow(hWnd, SW_SHOWMAXIMIZED);
  157. UpdateWindow(hWnd);
  158. //
  159. // Welcome dialog.
  160. //
  161. DialogBox(g_ai.hInstance,
  162. MAKEINTRESOURCE(IDD_WELCOME),
  163. hWnd,
  164. WelcomeDialogProc);
  165. if (g_ai.fClosing) {
  166. break;
  167. }
  168. //
  169. // Checking for installed components dialog.
  170. //
  171. DialogBox(g_ai.hInstance,
  172. MAKEINTRESOURCE(IDD_CHECK_INSTALL),
  173. hWnd,
  174. CheckComponentDialogProc);
  175. if (g_ai.fClosing) {
  176. break;
  177. }
  178. //
  179. // Checking for free disk space dialog.
  180. //
  181. DialogBox(g_ai.hInstance,
  182. MAKEINTRESOURCE(IDD_DISKSPACE),
  183. hWnd,
  184. CheckFreeDiskSpaceDialogProc);
  185. if (g_ai.fClosing) {
  186. break;
  187. }
  188. //
  189. // Ready to copy files dialog
  190. //
  191. DialogBox(g_ai.hInstance,
  192. MAKEINTRESOURCE(IDD_READYTO_COPY),
  193. hWnd,
  194. ReadyToCopyDialogProc);
  195. if (g_ai.fClosing) {
  196. break;
  197. }
  198. //
  199. // Copying files progress dialog.
  200. //
  201. DialogBox(g_ai.hInstance,
  202. MAKEINTRESOURCE(IDD_COPYFILES),
  203. hWnd,
  204. CopyFilesDialogProc);
  205. if (g_ai.fClosing) {
  206. break;
  207. }
  208. //
  209. // Create the shortcuts - even the bad one.
  210. //
  211. CreateShortcuts(hWnd);
  212. //
  213. // Readme dialog.
  214. //
  215. DialogBox(g_ai.hInstance,
  216. MAKEINTRESOURCE(IDD_README),
  217. hWnd,
  218. ViewReadmeDialogProc);
  219. if (g_ai.fClosing) {
  220. break;
  221. }
  222. //
  223. // Reboot dialog.
  224. //
  225. DialogBox(g_ai.hInstance,
  226. MAKEINTRESOURCE(IDD_REBOOT),
  227. hWnd,
  228. RebootDialogProc);
  229. break;
  230. case WM_DESTROY:
  231. PostQuitMessage(0);
  232. break;
  233. default:
  234. return DefWindowProc(hWnd, uMsg, wParam, lParam);
  235. }
  236. return FALSE;
  237. }