|
|
1.1 root 1: /*
2: Legal Notice: Some portions of the source code contained in this file were
3: derived from the source code of Encryption for the Masses 2.02a, which is
4: Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
5: Agreement for Encryption for the Masses'. Modifications and additions to
6: the original source code (contained in this file) and all other portions of
7: this file are Copyright (c) 2003-2008 TrueCrypt Foundation and are governed
1.1.1.5 ! root 8: by the TrueCrypt License 2.6 the full text of which is contained in the
1.1 root 9: file License.txt included in TrueCrypt binary and source code distribution
10: packages. */
11:
12: #include "Tcdefs.h"
13:
14: #include "SelfExtract.h"
15: #include "Wizard.h"
16: #include "Dlgcode.h"
17: #include "Language.h"
18: #include "Common/Resource.h"
19: #include "Resource.h"
20:
21: enum wizard_pages
22: {
23: INTRO_PAGE,
24: WIZARD_MODE_PAGE,
25: INSTALL_OPTIONS_PAGE,
26: INSTALL_PROGRESS_PAGE,
27: EXTRACTION_OPTIONS_PAGE,
28: EXTRACTION_PROGRESS_PAGE
29: };
30:
31: HWND hCurPage = NULL; /* Handle to current wizard page */
32: int nCurPageNo = -1; /* The current wizard page */
33: char WizardDestInstallPath [TC_MAX_PATH];
34: char WizardDestExtractPath [TC_MAX_PATH];
35: char SelfFile [TC_MAX_PATH];
36:
37: HBITMAP hbmWizardBitmapRescaled = NULL;
38:
39: BOOL bExtractOnly = FALSE;
40: BOOL bLicenseAccepted = FALSE;
41: BOOL bOpenContainingFolder = TRUE;
42: BOOL bExtractionSuccessful = FALSE;
43: BOOL bStartInstall = FALSE;
44: BOOL bStartExtraction = FALSE;
45: BOOL bInProgress = FALSE;
46:
47: int nPbar = 0; /* Control ID of progress bar */
48:
1.1.1.3 root 49: void localcleanupwiz (void)
1.1 root 50: {
51: /* Delete buffered bitmaps (if any) */
52: if (hbmWizardBitmapRescaled != NULL)
53: {
54: DeleteObject ((HGDIOBJ) hbmWizardBitmapRescaled);
55: hbmWizardBitmapRescaled = NULL;
56: }
57: }
58:
59: static void InitWizardDestInstallPath (void)
60: {
61:
62: if (strlen (WizardDestInstallPath) < 2)
63: {
64: strcpy (WizardDestInstallPath, InstallationPath);
65: if (WizardDestInstallPath [strlen (WizardDestInstallPath) - 1] != '\\')
66: {
67: strcat (WizardDestInstallPath, "\\");
68: }
69: }
70: }
71:
72: void LoadPage (HWND hwndDlg, int nPageNo)
73: {
74: RECT rD, rW;
75:
76: if (hCurPage != NULL)
77: {
78: DestroyWindow (hCurPage);
79: }
80:
81: GetWindowRect (GetDlgItem (hwndDlg, IDC_POS_BOX), &rW);
82:
83: nCurPageNo = nPageNo;
84:
85: switch (nPageNo)
86: {
87: case INTRO_PAGE:
88: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INTRO_PAGE_DLG), hwndDlg,
89: (DLGPROC) PageDialogProc);
90: break;
91:
92: case WIZARD_MODE_PAGE:
93: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_WIZARD_MODE_PAGE_DLG), hwndDlg,
94: (DLGPROC) PageDialogProc);
95: break;
96:
97: case INSTALL_OPTIONS_PAGE:
98: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INSTALL_OPTIONS_PAGE_DLG), hwndDlg,
99: (DLGPROC) PageDialogProc);
100: break;
101:
102: case INSTALL_PROGRESS_PAGE:
103: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PROGRESS_PAGE_DLG), hwndDlg,
104: (DLGPROC) PageDialogProc);
105: break;
106:
107: case EXTRACTION_OPTIONS_PAGE:
108: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_EXTRACTION_OPTIONS_PAGE_DLG), hwndDlg,
109: (DLGPROC) PageDialogProc);
110: break;
111:
112: case EXTRACTION_PROGRESS_PAGE:
113: hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PROGRESS_PAGE_DLG), hwndDlg,
114: (DLGPROC) PageDialogProc);
115: break;
116: }
117:
118: rD.left = 15;
119: rD.top = 45;
120: rD.right = 0;
121: rD.bottom = 0;
122: MapDialogRect (hwndDlg, &rD);
123:
124: if (hCurPage != NULL)
125: {
126: MoveWindow (hCurPage, rD.left, rD.top, rW.right - rW.left, rW.bottom - rW.top, TRUE);
127: ShowWindow (hCurPage, SW_SHOWNORMAL);
128: }
129:
130: /* Refresh the graphics (white background of some texts, etc.) */
131: RefreshUIGFX ();
132: }
133:
134:
135: /* Except in response to the WM_INITDIALOG message, the dialog box procedure
136: should return nonzero if it processes the message, and zero if it does
137: not. - see DialogProc */
138: BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
139: {
140: static char PageDebugId[128];
141: WORD lw = LOWORD (wParam);
142: WORD hw = HIWORD (wParam);
143:
144: hCurPage = hwndDlg;
145:
146: switch (uMsg)
147: {
148: case WM_INITDIALOG:
149: LocalizeDialog (hwndDlg, "IDD_INSTL_DLG");
150:
151: sprintf (PageDebugId, "SETUP_WIZARD_PAGE_%d", nCurPageNo);
152: LastDialogId = PageDebugId;
153:
154: switch (nCurPageNo)
155: {
156: case INTRO_PAGE:
157: {
158: char *licenseText = NULL;
159:
160: licenseText = GetLegalNotices ();
161: if (licenseText != NULL)
162: {
163: SetWindowText (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), licenseText);
164: free (licenseText);
165: }
166: else
167: {
168: Error("CANNOT_DISPLAY_LICENSE");
1.1.1.5 ! root 169: exit (1);
1.1 root 170: }
171:
172: /* Some of the following texts cannot be localized by third parties for legal reasons. */
173:
1.1.1.5 ! root 174: SetCheckBox (hwndDlg, IDC_AGREE, bLicenseAccepted);
1.1 root 175:
1.1.1.2 root 176: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), L"License");
177: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), L"You must accept these license terms before you can use, extract, or install TrueCrypt.");
1.1.1.5 ! root 178: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), L"IMPORTANT: By checking the checkbox below and clicking Accept, you accept these license terms and agree to be bound by and to comply with them. Click the 'arrow down' icon to see the rest of the license.");
1.1 root 179: //SendMessage (GetDlgItem (hwndDlg, IDC_BOX_HELP), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
180:
1.1.1.2 root 181: SetWindowTextW (GetDlgItem (hwndDlg, IDC_AGREE), L"I a&ccept and agree to be bound by the license terms");
1.1.1.5 ! root 182: //SetWindowTextW (GetDlgItem (hwndDlg, IDC_DISAGREE), L"I &do not accept the license terms");
1.1 root 183:
184: //SendMessage (GetDlgItem (hwndDlg, IDC_AGREE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
185: //SendMessage (GetDlgItem (hwndDlg, IDC_DISAGREE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
186:
187: EnableWindow (GetDlgItem (hwndDlg, IDC_AGREE), TRUE);
188:
189: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), L"&Accept"); // Cannot be localized by third parties for legal reasons.
190: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
191: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
192:
193: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), bLicenseAccepted);
194: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
195: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), bLicenseAccepted);
1.1.1.5 ! root 196:
! 197: // Left margin for license text
! 198: SendMessage (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), EM_SETMARGINS, (WPARAM) EC_LEFTMARGIN, (LPARAM) CompensateXDPI (4));
1.1 root 199: }
200: return 1;
201:
202: case WIZARD_MODE_PAGE:
203:
204: if (bRepairMode)
205: {
206: SetWindowTextW (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), GetString ("REPAIR_REINSTALL"));
207: bExtractOnly = FALSE;
208: }
209:
210: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_MODE_TITLE"));
211: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_MODE_INFO"));
212:
213: SendMessage (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
214: SendMessage (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_EXTRACT_ONLY), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
215:
216: CheckButton (GetDlgItem (hwndDlg, bExtractOnly ? IDC_WIZARD_MODE_EXTRACT_ONLY : IDC_WIZARD_MODE_INSTALL));
217:
218: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SETUP_MODE_HELP_EXTRACT"));
219:
220: if (!bRepairMode)
221: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP2), GetString ("SETUP_MODE_HELP_INSTALL"));
222:
223: EnableWindow (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_EXTRACT_ONLY), !bRepairMode);
224: EnableWindow (GetDlgItem (hwndDlg, IDC_BOX_HELP), !bRepairMode);
225: EnableWindow (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), TRUE);
226:
227: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
228: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
229: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
230: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
231: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
232:
233: return 1;
234:
235: case EXTRACTION_OPTIONS_PAGE:
236:
237: if (strlen(WizardDestExtractPath) < 2)
238: {
239: strcpy (WizardDestExtractPath, SetupFilesDir);
240: strncat (WizardDestExtractPath, "TrueCrypt\\", sizeof (WizardDestExtractPath) - strlen (WizardDestExtractPath) - 1);
241: }
242:
243: SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
244:
245: SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
246:
247: SetCheckBox (hwndDlg, IDC_OPEN_CONTAINING_FOLDER, bOpenContainingFolder);
248:
249: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("EXTRACTION_OPTIONS_TITLE"));
250: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("EXTRACTION_OPTIONS_INFO"));
251: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION"));
252:
253: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("EXTRACT"));
254: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
255: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
256: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
257: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
258:
259: return 1;
260:
261: case EXTRACTION_PROGRESS_PAGE:
262:
263: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("EXTRACTING_VERB"));
264: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("EXTRACTION_PROGRESS_INFO"));
265: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
266:
267: if (bStartExtraction)
268: {
269: /* Start extraction */
270:
271: LastDialogId = "EXTRACTION_IN_PROGRESS";
272:
273: WaitCursor ();
274:
275: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
276: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
277: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
278: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
279:
280: if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
281: strcat (WizardDestExtractPath, "\\");
282:
283: strcpy (DestExtractPath, WizardDestExtractPath);
284:
285: InitProgressBar ();
286:
287: bInProgress = TRUE;
288: bStartExtraction = FALSE;
289:
1.1.1.5 ! root 290: _beginthread (ExtractAllFilesThread, 0, (void *) hwndDlg);
1.1 root 291: }
292: else
293: {
294: NormalCursor ();
295:
296: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
297: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
298: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
299: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
300: }
301:
302: return 1;
303:
304: case INSTALL_OPTIONS_PAGE:
305:
306: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_OPTIONS_TITLE"));
307: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_OPTIONS_INFO"));
308: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION"));
309:
310: InitWizardDestInstallPath ();
311:
312: SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
313:
314: SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
315:
316: // System Restore
317: SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, bSystemRestore);
318: if (SystemRestoreDll == 0)
319: {
320: SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, FALSE);
321: EnableWindow (GetDlgItem (hwndDlg, IDC_SYSTEM_RESTORE), FALSE);
322: }
323:
1.1.1.5 ! root 324: #if 0
1.1.1.3 root 325: // Swap files
326: SetCheckBox (hwndDlg, IDC_DISABLE_PAGING_FILES, bDisableSwapFiles);
327: if (nCurrentOS == WIN_2000)
328: {
329: bDisableSwapFiles = FALSE;
330: SetCheckBox (hwndDlg, IDC_DISABLE_PAGING_FILES, FALSE);
331: EnableWindow (GetDlgItem (hwndDlg, IDC_DISABLE_PAGING_FILES), FALSE);
332: }
1.1.1.5 ! root 333: #endif // 0
1.1.1.3 root 334:
1.1 root 335: SetCheckBox (hwndDlg, IDC_ALL_USERS, bForAllUsers);
336: SetCheckBox (hwndDlg, IDC_FILE_TYPE, bRegisterFileExt);
337: SetCheckBox (hwndDlg, IDC_PROG_GROUP, bAddToStartMenu);
338: SetCheckBox (hwndDlg, IDC_DESKTOP_ICON, bDesktopIcon);
339:
340: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("INSTALL"));
341: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
342:
343: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
344: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
345: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
346: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
347:
348: return 1;
349:
350: case INSTALL_PROGRESS_PAGE:
351:
352: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_PROGRESS_TITLE"));
353: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_PROGRESS_INFO"));
354: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
355: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
356:
357: if (bStartInstall)
358: {
359: /* Start install */
360:
361: LastDialogId = "INSTALL_IN_PROGRESS";
362:
363: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
364:
365: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
366: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
367: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
368: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
369:
370: InitProgressBar ();
371:
372: if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
373: strcat (WizardDestInstallPath, "\\");
374:
375: strcpy (InstallationPath, WizardDestInstallPath);
376:
377: WaitCursor ();
378:
379: bInProgress = TRUE;
380: bStartInstall = FALSE;
381:
1.1.1.5 ! root 382: _beginthread (DoInstall, 0, (void *) hwndDlg);
1.1 root 383: }
384: else
385: {
386: NormalCursor ();
387:
388: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
389: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
390: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
391: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
392:
393: }
394:
395: return 1;
396:
397: }
398: return 0;
399:
400: case WM_HELP:
401: if (bLicenseAccepted)
402: OpenPageHelp (GetParent (hwndDlg), nCurPageNo);
403:
404: return 1;
405:
1.1.1.3 root 406: case WM_ENDSESSION:
407: EndDialog (MainDlg, 0);
408: localcleanup ();
409: return 0;
410:
1.1 root 411:
412: case WM_COMMAND:
413:
414: if (lw == IDC_AGREE && nCurPageNo == INTRO_PAGE)
415: {
1.1.1.5 ! root 416: EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), IsButtonChecked (GetDlgItem (hwndDlg, IDC_AGREE)));
1.1 root 417: return 1;
418: }
419:
420: if (lw == IDC_WIZARD_MODE_EXTRACT_ONLY && nCurPageNo == WIZARD_MODE_PAGE)
421: {
422: bExtractOnly = TRUE;
423: return 1;
424: }
425:
426: if (lw == IDC_WIZARD_MODE_INSTALL && nCurPageNo == WIZARD_MODE_PAGE)
427: {
428: bExtractOnly = FALSE;
429: return 1;
430: }
431:
432: if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE && hw == EN_CHANGE )
433: {
434: EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
435: return 1;
436: }
437:
438: if ( nCurPageNo == INSTALL_OPTIONS_PAGE && hw == EN_CHANGE )
439: {
440: EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
441: return 1;
442: }
443:
444: if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE )
445: {
446: switch (lw)
447: {
448: case IDC_BROWSE:
449: if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestExtractPath))
450: {
451: if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
452: {
453: strcat (WizardDestExtractPath, "\\");
454: }
455: SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
456: }
457: return 1;
458:
459: case IDC_OPEN_CONTAINING_FOLDER:
1.1.1.2 root 460: bOpenContainingFolder = IsButtonChecked (GetDlgItem (hCurPage, IDC_OPEN_CONTAINING_FOLDER));
1.1 root 461: return 1;
462: }
463: }
464:
465: if ( nCurPageNo == INSTALL_OPTIONS_PAGE )
466: {
467: switch (lw)
468: {
469: case IDC_BROWSE:
470: if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestInstallPath))
471: {
472: if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
473: {
474: strcat (WizardDestInstallPath, "\\");
475: }
476: SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
477: }
478: return 1;
479:
480: case IDC_SYSTEM_RESTORE:
481: bSystemRestore = IsButtonChecked (GetDlgItem (hCurPage, IDC_SYSTEM_RESTORE));
482: return 1;
483:
1.1.1.5 ! root 484: #if 0
1.1.1.3 root 485: case IDC_DISABLE_PAGING_FILES:
486:
487: bDisableSwapFiles = IsButtonChecked (GetDlgItem (hCurPage, IDC_DISABLE_PAGING_FILES));
488:
489: if (!bDisableSwapFiles
490: && AskWarnNoYes("CONFIRM_NOT_DISABLING_SWAP_FILES") == IDNO)
491: {
492: bDisableSwapFiles = TRUE;
493: SetCheckBox (hwndDlg, IDC_DISABLE_PAGING_FILES, bDisableSwapFiles);
494: }
495:
496: return 1;
1.1.1.5 ! root 497: #endif // 0
1.1.1.3 root 498:
1.1 root 499: case IDC_ALL_USERS:
500: bForAllUsers = IsButtonChecked (GetDlgItem (hCurPage, IDC_ALL_USERS));
501: return 1;
502:
503: case IDC_FILE_TYPE:
504: bRegisterFileExt = IsButtonChecked (GetDlgItem (hCurPage, IDC_FILE_TYPE));
505: return 1;
506:
507: case IDC_PROG_GROUP:
508: bAddToStartMenu = IsButtonChecked (GetDlgItem (hCurPage, IDC_PROG_GROUP));
509: return 1;
510:
511: case IDC_DESKTOP_ICON:
512: bDesktopIcon = IsButtonChecked (GetDlgItem (hCurPage, IDC_DESKTOP_ICON));
513: return 1;
514:
515: }
516: }
517:
518: return 0;
519: }
520:
521: return 0;
522: }
523:
524: void InitProgressBar (void)
525: {
526: HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
527: SendMessage (hProgressBar, PBM_SETRANGE32, 0, 100);
528: SendMessage (hProgressBar, PBM_SETSTEP, 1, 0);
529: InvalidateRect (hProgressBar, NULL, TRUE);
530: }
531:
532: // Must always return TRUE
533: BOOL UpdateProgressBarProc (int nPercent)
534: {
535: HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
536: SendMessage (hProgressBar, PBM_SETPOS, (int) (100.0 * nPercent / 100), 0);
537: InvalidateRect (hProgressBar, NULL, TRUE);
538: ShowWindow(hProgressBar, SW_HIDE);
539: ShowWindow(hProgressBar, SW_SHOW);
540: // Prevent the IDC_LOG_WINDOW item from partially disappearing at higher DPIs
541: ShowWindow(GetDlgItem (hCurPage, IDC_LOG_WINDOW), SW_HIDE);
542: ShowWindow(GetDlgItem (hCurPage, IDC_LOG_WINDOW), SW_SHOW);
543: RefreshUIGFX();
544: return TRUE;
545: }
546:
547: void RefreshUIGFX (void)
548: {
549: InvalidateRect (GetDlgItem (MainDlg, IDC_SETUP_WIZARD_BKG), NULL, TRUE);
550: InvalidateRect (GetDlgItem (MainDlg, IDC_BOX_TITLE), NULL, TRUE);
551: InvalidateRect (GetDlgItem (MainDlg, IDC_BOX_INFO), NULL, TRUE);
552: InvalidateRect (GetDlgItem (MainDlg, IDC_BITMAP_SETUP_WIZARD), NULL, TRUE);
553: InvalidateRect (GetDlgItem (MainDlg, IDC_HR), NULL, TRUE);
554: // Prevent these items from disappearing at higher DPIs
555: ShowWindow(GetDlgItem(MainDlg, IDC_HR), SW_HIDE);
556: ShowWindow(GetDlgItem(MainDlg, IDC_HR), SW_SHOW);
557: ShowWindow(GetDlgItem(MainDlg, IDC_HR_BOTTOM), SW_HIDE);
558: ShowWindow(GetDlgItem(MainDlg, IDC_HR_BOTTOM), SW_SHOW);
559: ShowWindow(GetDlgItem(MainDlg, IDC_BOX_INFO), SW_HIDE);
560: ShowWindow(GetDlgItem(MainDlg, IDC_BOX_INFO), SW_SHOW);
561: ShowWindow(GetDlgItem(MainDlg, IDC_BOX_TITLE), SW_HIDE);
562: ShowWindow(GetDlgItem(MainDlg, IDC_BOX_TITLE), SW_SHOW);
563: }
564:
565:
566: /* Except in response to the WM_INITDIALOG message, the dialog box procedure
567: should return nonzero if it processes the message, and zero if it does
568: not. - see DialogProc */
569: BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
570: {
571: WORD lw = LOWORD (wParam);
572:
573: switch (uMsg)
574: {
575: case WM_INITDIALOG:
576: {
577: RECT rec;
578:
579: GetModuleFileName (NULL, SelfFile, sizeof (SelfFile));
580:
581: MainDlg = hwndDlg;
1.1.1.3 root 582:
583: if (!CreateAppSetupMutex ())
584: AbortProcess ("TC_INSTALLER_IS_RUNNING");
585:
1.1 root 586: InitDialog (hwndDlg);
587: LocalizeDialog (hwndDlg, "IDD_INSTL_DLG");
588:
589: // Resize the bitmap if the user has a non-default DPI
590: if (ScreenDPI != USER_DEFAULT_SCREEN_DPI)
591: {
592: hbmWizardBitmapRescaled = RenderBitmap (MAKEINTRESOURCE (IDB_SETUP_WIZARD),
593: GetDlgItem (hwndDlg, IDC_BITMAP_SETUP_WIZARD),
594: 0, 0, 0, 0, FALSE, TRUE);
595: }
596:
597: // Gfx area background (must not keep aspect ratio; must retain Windows-imposed distortion)
598: GetClientRect (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_GFX_AREA), &rec);
599: SetWindowPos (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_BKG), HWND_TOP, 0, 0, rec.right, rec.bottom, SWP_NOMOVE);
600:
601: nPbar = IDC_PROGRESS_BAR;
602:
603: SendMessage (GetDlgItem (hwndDlg, IDC_BOX_TITLE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
604:
605: SetWindowTextW (hwndDlg, lpszTitle);
606:
607: if (bDevm)
608: {
609: InitWizardDestInstallPath ();
610: bSystemRestore = FALSE;
611: bRegisterFileExt = FALSE;
612: bAddToStartMenu = FALSE;
613: bDesktopIcon = TRUE;
614: bLicenseAccepted = TRUE;
615: bStartInstall = TRUE;
616: LoadPage (hwndDlg, INSTALL_PROGRESS_PAGE);
617: }
618: else
619: LoadPage (hwndDlg, INTRO_PAGE);
1.1.1.3 root 620:
1.1 root 621: }
622: return 0;
623:
624: case WM_SYSCOMMAND:
625: if (lw == IDC_ABOUT)
626: {
627: if (bLicenseAccepted)
628: DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc);
629:
630: return 1;
631: }
632: return 0;
633:
634: case WM_HELP:
635: if (bLicenseAccepted)
636: OpenPageHelp (hwndDlg, nCurPageNo);
637:
638: return 1;
639:
640: case WM_COMMAND:
641: if (lw == IDHELP)
642: {
643: if (bLicenseAccepted)
644: OpenPageHelp (hwndDlg, nCurPageNo);
645:
646: return 1;
647: }
648: if (lw == IDCANCEL)
649: {
650: PostMessage (hwndDlg, WM_CLOSE, 0, 0);
651: return 1;
652: }
653: if (lw == IDC_NEXT)
654: {
655: if (nCurPageNo == INTRO_PAGE)
656: {
657: if (!IsButtonChecked (GetDlgItem (hCurPage, IDC_AGREE)))
658: {
659: bLicenseAccepted = FALSE;
660: return 1;
661: }
662: bLicenseAccepted = TRUE;
663: EnableWindow (GetDlgItem (hwndDlg, IDHELP), TRUE);
664: }
665:
666: else if (nCurPageNo == WIZARD_MODE_PAGE)
667: {
1.1.1.5 ! root 668: if (IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY)))
1.1 root 669: {
1.1.1.5 ! root 670: if (IsUacSupported()
! 671: && AskWarnYesNo ("TRAVELER_UAC_NOTE") == IDNO)
! 672: {
! 673: return 1;
! 674: }
! 675:
! 676: bExtractOnly = TRUE;
1.1 root 677: nCurPageNo = EXTRACTION_OPTIONS_PAGE - 1;
678: }
679: }
680:
681: else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
682: {
683: GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
684: bStartExtraction = TRUE;
685: }
686:
687: else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
688: {
689: GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
690: bStartInstall = TRUE;
691: }
692:
693: else if (nCurPageNo == INSTALL_PROGRESS_PAGE)
694: {
695: PostMessage (hwndDlg, WM_CLOSE, 0, 0);
696: return 1;
697: }
698:
699: else if (nCurPageNo == EXTRACTION_PROGRESS_PAGE)
700: {
701: PostMessage (hwndDlg, WM_CLOSE, 0, 0);
702: return 1;
703: }
704:
705: LoadPage (hwndDlg, ++nCurPageNo);
706:
707: return 1;
708: }
709:
710: if (lw == IDC_PREV)
711: {
712: if (nCurPageNo == WIZARD_MODE_PAGE)
713: {
714: bExtractOnly = IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY));
715: }
716:
717: else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
718: {
719: GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
720: nCurPageNo = WIZARD_MODE_PAGE + 1;
721: }
722:
723: else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
724: {
725: GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
726: }
727:
728: LoadPage (hwndDlg, --nCurPageNo);
729:
730: return 1;
731: }
732:
733: return 0;
734:
735: case WM_CTLCOLORSTATIC:
736:
737: /* This maintains the white background under the transparent-backround texts */
738:
739: SetBkMode ((HDC) wParam, TRANSPARENT);
740: return ((LONG) (HBRUSH) (GetStockObject (NULL_BRUSH)));
741:
742: case WM_ERASEBKGND:
743: return 0;
744:
745: case TC_APPMSG_INSTALL_SUCCESS:
746:
747: /* Installation completed successfully */
748:
749: bInProgress = FALSE;
750:
751: NormalCursor ();
752:
1.1.1.4 root 753: SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString (bRestartRequired ? "RESTART" : "FINALIZE"));
1.1 root 754: EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
755: EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
756: EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
757: EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
758:
759: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("SETUP_FINISHED_TITLE"));
1.1.1.5 ! root 760: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString (bRestartRequired ? "SETUP_FINISHED_INFO_RESTART_REQUIRED" : "SETUP_FINISHED_INFO"));
1.1 root 761:
762: RefreshUIGFX ();
763: return 1;
764:
765: case TC_APPMSG_INSTALL_FAILURE:
766:
767: /* Extraction failed */
768:
769: bInProgress = FALSE;
770:
771: NormalCursor ();
772:
773: nCurPageNo = INSTALL_OPTIONS_PAGE;
774: LoadPage (hwndDlg, nCurPageNo);
775: return 1;
776:
777: case TC_APPMSG_EXTRACTION_SUCCESS:
778:
779: /* Extraction completed successfully */
780:
781: InvalidateRect (GetDlgItem (MainDlg, IDD_INSTL_DLG), NULL, TRUE);
782:
783: bInProgress = FALSE;
784: bExtractionSuccessful = TRUE;
785:
786: NormalCursor ();
787:
788: StatusMessage (hCurPage, "EXTRACTION_FINISHED_INFO");
789:
790: SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
791: EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
792: EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
793: EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
794: EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
795:
796: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("EXTRACTION_FINISHED_TITLE"));
797: SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString ("EXTRACTION_FINISHED_INFO"));
798:
799: RefreshUIGFX ();
800: UpdateProgressBarProc(100);
801:
802: Info ("EXTRACTION_FINISHED_INFO");
803:
804: return 1;
805:
806: case TC_APPMSG_EXTRACTION_FAILURE:
807:
808: /* Extraction failed */
809:
810: bInProgress = FALSE;
811:
812: NormalCursor ();
813:
814: StatusMessage (hCurPage, "EXTRACTION_FAILED");
815:
816: UpdateProgressBarProc(0);
817:
818: Error ("EXTRACTION_FAILED");
819:
820: nCurPageNo = EXTRACTION_OPTIONS_PAGE;
821: LoadPage (hwndDlg, nCurPageNo);
822: return 1;
823:
824: case WM_CLOSE:
1.1.1.3 root 825:
1.1 root 826: if (bInProgress)
827: {
828: NormalCursor();
829: if (AskNoYes("CONFIRM_EXIT_UNIVERSAL") == IDNO)
830: {
831: return 1;
832: }
833: WaitCursor ();
834: }
835:
1.1.1.3 root 836: if (bRestartRequired)
837: {
1.1.1.4 root 838: if (AskWarnYesNo ("TC_INSTALLER_REQUIRING_RESTART") == IDYES)
1.1.1.3 root 839: {
840: RestartComputer();
841: }
842: return 1;
843: }
1.1 root 844:
845: if (bOpenContainingFolder && bExtractOnly && bExtractionSuccessful)
846: ShellExecute (NULL, "open", WizardDestExtractPath, NULL, NULL, SW_SHOWNORMAL);
847:
848: EndDialog (hwndDlg, IDCANCEL);
849: return 1;
850: }
851:
852: return 0;
853: }
854:
855:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.