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