Annotation of truecrypt/setup/wizard.c, revision 1.1.1.4

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.3   root        8:  by the TrueCrypt License 2.5 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");
                    169:                                        PostMessage (MainDlg, WM_CLOSE, 0, 0);
                    170:                                }
                    171: 
                    172:                                /* Some of the following texts cannot be localized by third parties for legal reasons. */
                    173: 
                    174:                                CheckButton (GetDlgItem (hwndDlg, bLicenseAccepted ? IDC_AGREE : IDC_DISAGREE));
                    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.");
                    178:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), L"IMPORTANT: By selecting the first option 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");
                    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:                                EnableWindow (GetDlgItem (hwndDlg, IDC_DISAGREE), 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);
                    197:                        }
                    198:                        return 1;
                    199: 
                    200:                case WIZARD_MODE_PAGE:
                    201: 
                    202:                        if (bRepairMode)
                    203:                        {
                    204:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), GetString ("REPAIR_REINSTALL"));
                    205:                                bExtractOnly = FALSE;
                    206:                        }
                    207: 
                    208:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_MODE_TITLE"));
                    209:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_MODE_INFO"));
                    210: 
                    211:                        SendMessage (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
                    212:                        SendMessage (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_EXTRACT_ONLY), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
                    213: 
                    214:                        CheckButton (GetDlgItem (hwndDlg, bExtractOnly ? IDC_WIZARD_MODE_EXTRACT_ONLY : IDC_WIZARD_MODE_INSTALL));
                    215: 
                    216:                        SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SETUP_MODE_HELP_EXTRACT"));
                    217: 
                    218:                        if (!bRepairMode)
                    219:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP2), GetString ("SETUP_MODE_HELP_INSTALL"));
                    220: 
                    221:                        EnableWindow (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_EXTRACT_ONLY), !bRepairMode);
                    222:                        EnableWindow (GetDlgItem (hwndDlg, IDC_BOX_HELP), !bRepairMode);
                    223:                        EnableWindow (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), TRUE);
                    224: 
                    225:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
                    226:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
                    227:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
                    228:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
                    229:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
                    230: 
                    231:                        return 1;
                    232: 
                    233:                case EXTRACTION_OPTIONS_PAGE:
                    234: 
                    235:                        if (strlen(WizardDestExtractPath) < 2)
                    236:                        { 
                    237:                                strcpy (WizardDestExtractPath, SetupFilesDir);
                    238:                                strncat (WizardDestExtractPath, "TrueCrypt\\", sizeof (WizardDestExtractPath) - strlen (WizardDestExtractPath) - 1);
                    239:                        }
                    240: 
                    241:                        SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
                    242: 
                    243:                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
                    244: 
                    245:                        SetCheckBox (hwndDlg, IDC_OPEN_CONTAINING_FOLDER, bOpenContainingFolder);
                    246: 
                    247:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("EXTRACTION_OPTIONS_TITLE"));
                    248:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("EXTRACTION_OPTIONS_INFO"));
                    249:                        SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION"));
                    250: 
                    251:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("EXTRACT"));
                    252:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
                    253:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
                    254:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
                    255:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
                    256: 
                    257:                        return 1;
                    258: 
                    259:                case EXTRACTION_PROGRESS_PAGE:
                    260: 
                    261:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("EXTRACTING_VERB"));
                    262:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("EXTRACTION_PROGRESS_INFO"));
                    263:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
                    264: 
                    265:                        if (bStartExtraction)
                    266:                        {
                    267:                                /* Start extraction */
                    268: 
                    269:                                LastDialogId = "EXTRACTION_IN_PROGRESS";
                    270: 
                    271:                                WaitCursor ();
                    272: 
                    273:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
                    274:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
                    275:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
                    276:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
                    277: 
                    278:                                if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
                    279:                                        strcat (WizardDestExtractPath, "\\");
                    280: 
                    281:                                strcpy (DestExtractPath, WizardDestExtractPath);
                    282: 
                    283:                                InitProgressBar ();
                    284: 
                    285:                                bInProgress = TRUE;
                    286:                                bStartExtraction = FALSE;
                    287: 
                    288:                                _beginthread (ExtractAllFilesThread, 16384, (void *) hwndDlg);
                    289:                        }
                    290:                        else
                    291:                        {
                    292:                                NormalCursor ();
                    293: 
                    294:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
                    295:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
                    296:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
                    297:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
                    298:                        }
                    299: 
                    300:                        return 1;
                    301: 
                    302:                case INSTALL_OPTIONS_PAGE:
                    303: 
                    304:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_OPTIONS_TITLE"));
                    305:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_OPTIONS_INFO"));
                    306:                        SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION"));
                    307: 
                    308:                        InitWizardDestInstallPath ();
                    309: 
                    310:                        SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
                    311: 
                    312:                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
                    313: 
                    314:                        // System Restore
                    315:                        SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, bSystemRestore);
                    316:                        if (SystemRestoreDll == 0)
                    317:                        {
                    318:                                SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, FALSE);
                    319:                                EnableWindow (GetDlgItem (hwndDlg, IDC_SYSTEM_RESTORE), FALSE);
                    320:                        }
                    321: 
1.1.1.3   root      322:                        // Swap files
                    323:                        SetCheckBox (hwndDlg, IDC_DISABLE_PAGING_FILES, bDisableSwapFiles);
                    324:                        if (nCurrentOS == WIN_2000)
                    325:                        {
                    326:                                bDisableSwapFiles = FALSE;
                    327:                                SetCheckBox (hwndDlg, IDC_DISABLE_PAGING_FILES, FALSE);
                    328:                                EnableWindow (GetDlgItem (hwndDlg, IDC_DISABLE_PAGING_FILES), FALSE);
                    329:                        }
                    330: 
1.1       root      331:                        SetCheckBox (hwndDlg, IDC_ALL_USERS, bForAllUsers);
                    332:                        SetCheckBox (hwndDlg, IDC_FILE_TYPE, bRegisterFileExt);
                    333:                        SetCheckBox (hwndDlg, IDC_PROG_GROUP, bAddToStartMenu);
                    334:                        SetCheckBox (hwndDlg, IDC_DESKTOP_ICON, bDesktopIcon);
                    335: 
                    336:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("INSTALL"));
                    337:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
                    338: 
                    339:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
                    340:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
                    341:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
                    342:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
                    343: 
                    344:                        return 1;
                    345: 
                    346:                case INSTALL_PROGRESS_PAGE:
                    347: 
                    348:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_PROGRESS_TITLE"));
                    349:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_PROGRESS_INFO"));
                    350:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
                    351:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
                    352: 
                    353:                        if (bStartInstall)
                    354:                        {
                    355:                                /* Start install */
                    356: 
                    357:                                LastDialogId = "INSTALL_IN_PROGRESS";
                    358: 
                    359:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
                    360: 
                    361:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
                    362:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
                    363:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
                    364:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
                    365: 
                    366:                                InitProgressBar ();
                    367: 
                    368:                                if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
                    369:                                        strcat (WizardDestInstallPath, "\\");
                    370: 
                    371:                                strcpy (InstallationPath, WizardDestInstallPath);
                    372: 
                    373:                                WaitCursor ();
                    374: 
                    375:                                bInProgress = TRUE;
                    376:                                bStartInstall = FALSE;
                    377: 
                    378:                                _beginthread (DoInstall, 16384, (void *) hwndDlg);
                    379:                        }
                    380:                        else
                    381:                        {
                    382:                                NormalCursor ();
                    383: 
                    384:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
                    385:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
                    386:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
                    387:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
                    388: 
                    389:                        }
                    390: 
                    391:                        return 1;
                    392: 
                    393:                }
                    394:                return 0;
                    395: 
                    396:        case WM_HELP:
                    397:                if (bLicenseAccepted)
                    398:                        OpenPageHelp (GetParent (hwndDlg), nCurPageNo);
                    399: 
                    400:                return 1;
                    401: 
1.1.1.3   root      402:        case WM_ENDSESSION:
                    403:                EndDialog (MainDlg, 0);
                    404:                localcleanup ();
                    405:                return 0;
                    406: 
1.1       root      407:        case TC_APPMSG_LOAD_LICENSE:
                    408:                {
                    409:                        char *licenseText = NULL;
                    410:                        licenseText = GetLegalNotices ();
                    411:                        if (licenseText != NULL)
                    412:                        {
                    413:                                SetWindowText (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), licenseText);
                    414:                                free (licenseText);
                    415:                        }
                    416:                        else
                    417:                        {
                    418:                                Error("CANNOT_DISPLAY_LICENSE");
                    419:                                PostMessage (MainDlg, WM_CLOSE, 0, 0);
                    420:                        }
                    421:                }
                    422:                return 1;
                    423: 
                    424: 
                    425:        case WM_COMMAND:
                    426: 
                    427:                if (lw == IDC_DISAGREE && nCurPageNo == INTRO_PAGE)
                    428:                {
                    429:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
                    430:                        return 1;
                    431:                }
                    432: 
                    433:                if (lw == IDC_AGREE && nCurPageNo == INTRO_PAGE)
                    434:                {
                    435:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
                    436:                        return 1;
                    437:                }
                    438: 
                    439:                if (lw == IDC_WIZARD_MODE_EXTRACT_ONLY && nCurPageNo == WIZARD_MODE_PAGE)
                    440:                {
                    441:                        bExtractOnly = TRUE;
                    442:                        return 1;
                    443:                }
                    444: 
                    445:                if (lw == IDC_WIZARD_MODE_INSTALL && nCurPageNo == WIZARD_MODE_PAGE)
                    446:                {
                    447:                        bExtractOnly = FALSE;
                    448:                        return 1;
                    449:                }
                    450: 
                    451:                if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE && hw == EN_CHANGE )
                    452:                {
                    453:                        EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
                    454:                        return 1;
                    455:                }
                    456: 
                    457:                if ( nCurPageNo == INSTALL_OPTIONS_PAGE && hw == EN_CHANGE )
                    458:                {
                    459:                        EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
                    460:                        return 1;
                    461:                }
                    462: 
                    463:                if (nCurPageNo == INTRO_PAGE && lw == IDC_LICENSE_TEXT && HIWORD (wParam) == EN_UPDATE)
                    464:                {
                    465:                        // License is read-only
                    466:                        SendMessage (hwndDlg, TC_APPMSG_LOAD_LICENSE, 0, 0);
                    467:                        return 1;
                    468:                }
                    469: 
                    470:                if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE )
                    471:                {
                    472:                        switch (lw)
                    473:                        {
                    474:                        case IDC_BROWSE:
                    475:                                if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestExtractPath))
                    476:                                {
                    477:                                        if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
                    478:                                        {
                    479:                                                strcat (WizardDestExtractPath, "\\");
                    480:                                        }
                    481:                                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
                    482:                                }
                    483:                                return 1;
                    484: 
                    485:                        case IDC_OPEN_CONTAINING_FOLDER:
1.1.1.2   root      486:                                bOpenContainingFolder = IsButtonChecked (GetDlgItem (hCurPage, IDC_OPEN_CONTAINING_FOLDER));
1.1       root      487:                                return 1;
                    488:                        }
                    489:                }
                    490: 
                    491:                if ( nCurPageNo == INSTALL_OPTIONS_PAGE )
                    492:                {
                    493:                        switch (lw)
                    494:                        {
                    495:                        case IDC_BROWSE:
                    496:                                if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestInstallPath))
                    497:                                {
                    498:                                        if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
                    499:                                        {
                    500:                                                strcat (WizardDestInstallPath, "\\");
                    501:                                        }
                    502:                                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
                    503:                                }
                    504:                                return 1;
                    505: 
                    506:                        case IDC_SYSTEM_RESTORE:
                    507:                                bSystemRestore = IsButtonChecked (GetDlgItem (hCurPage, IDC_SYSTEM_RESTORE));
                    508:                                return 1;
                    509: 
1.1.1.3   root      510:                        case IDC_DISABLE_PAGING_FILES:
                    511: 
                    512:                                bDisableSwapFiles = IsButtonChecked (GetDlgItem (hCurPage, IDC_DISABLE_PAGING_FILES));
                    513: 
                    514:                                if (!bDisableSwapFiles
                    515:                                        && AskWarnNoYes("CONFIRM_NOT_DISABLING_SWAP_FILES") == IDNO)
                    516:                                {
                    517:                                        bDisableSwapFiles = TRUE;
                    518:                                        SetCheckBox (hwndDlg, IDC_DISABLE_PAGING_FILES, bDisableSwapFiles);
                    519:                                }
                    520: 
                    521:                                return 1;
                    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: 
                    629:                        SetWindowTextW (hwndDlg, lpszTitle);
                    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);
                    688:                        }
                    689: 
                    690:                        else if (nCurPageNo == WIZARD_MODE_PAGE)
                    691:                        {
                    692:                                if (bExtractOnly = IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY)))
                    693:                                {
                    694:                                        nCurPageNo = EXTRACTION_OPTIONS_PAGE - 1;
                    695:                                }
                    696:                        }
                    697: 
                    698:                        else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
                    699:                        {
                    700:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
                    701:                                bStartExtraction = TRUE;
                    702:                        }
                    703:                        
                    704:                        else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
                    705:                        {
                    706:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
                    707:                                bStartInstall = TRUE;
                    708:                        }
                    709: 
                    710:                        else if (nCurPageNo == INSTALL_PROGRESS_PAGE)
                    711:                        {
                    712:                                PostMessage (hwndDlg, WM_CLOSE, 0, 0);
                    713:                                return 1;
                    714:                        }
                    715: 
                    716:                        else if (nCurPageNo == EXTRACTION_PROGRESS_PAGE)
                    717:                        {
                    718:                                PostMessage (hwndDlg, WM_CLOSE, 0, 0);
                    719:                                return 1;
                    720:                        }
                    721: 
                    722:                        LoadPage (hwndDlg, ++nCurPageNo);
                    723: 
                    724:                        return 1;
                    725:                }
                    726: 
                    727:                if (lw == IDC_PREV)
                    728:                {
                    729:                        if (nCurPageNo == WIZARD_MODE_PAGE)
                    730:                        {
                    731:                                bExtractOnly = IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY));
                    732:                        }
                    733: 
                    734:                        else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
                    735:                        {
                    736:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
                    737:                                nCurPageNo = WIZARD_MODE_PAGE + 1;
                    738:                        }
                    739: 
                    740:                        else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
                    741:                        {
                    742:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
                    743:                        }
                    744: 
                    745:                        LoadPage (hwndDlg, --nCurPageNo);
                    746: 
                    747:                        return 1;
                    748:                }
                    749: 
                    750:                return 0;
                    751: 
                    752:        case WM_CTLCOLORSTATIC:
                    753: 
                    754:                /* This maintains the white background under the transparent-backround texts */
                    755: 
                    756:                SetBkMode ((HDC) wParam, TRANSPARENT);
                    757:                return ((LONG) (HBRUSH) (GetStockObject (NULL_BRUSH)));
                    758: 
                    759:        case WM_ERASEBKGND:
                    760:                return 0;
                    761: 
                    762:        case TC_APPMSG_INSTALL_SUCCESS:
                    763:                
                    764:                /* Installation completed successfully */
                    765:                
                    766:                bInProgress = FALSE;
                    767: 
                    768:                NormalCursor ();
                    769: 
1.1.1.4 ! root      770:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString (bRestartRequired ? "RESTART" : "FINALIZE"));
1.1       root      771:                EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
                    772:                EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
                    773:                EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
                    774:                EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
                    775: 
                    776:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("SETUP_FINISHED_TITLE"));
                    777:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString ("SETUP_FINISHED_INFO"));
                    778: 
                    779:                RefreshUIGFX ();
                    780:                return 1;
                    781: 
                    782:        case TC_APPMSG_INSTALL_FAILURE:
                    783:                
                    784:                /* Extraction failed */
                    785:                
                    786:                bInProgress = FALSE;
                    787: 
                    788:                NormalCursor ();
                    789: 
                    790:                nCurPageNo = INSTALL_OPTIONS_PAGE;
                    791:                LoadPage (hwndDlg, nCurPageNo);
                    792:                return 1;
                    793: 
                    794:        case TC_APPMSG_EXTRACTION_SUCCESS:
                    795:                
                    796:                /* Extraction completed successfully */
                    797: 
                    798:                InvalidateRect (GetDlgItem (MainDlg, IDD_INSTL_DLG), NULL, TRUE);
                    799: 
                    800:                bInProgress = FALSE;
                    801:                bExtractionSuccessful = TRUE;
                    802: 
                    803:                NormalCursor ();
                    804: 
                    805:                StatusMessage (hCurPage, "EXTRACTION_FINISHED_INFO");
                    806: 
                    807:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
                    808:                EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
                    809:                EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
                    810:                EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
                    811:                EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
                    812: 
                    813:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("EXTRACTION_FINISHED_TITLE"));
                    814:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString ("EXTRACTION_FINISHED_INFO"));
                    815: 
                    816:                RefreshUIGFX ();
                    817:                UpdateProgressBarProc(100);
                    818: 
                    819:                Info ("EXTRACTION_FINISHED_INFO");
                    820: 
                    821:                return 1;
                    822: 
                    823:        case TC_APPMSG_EXTRACTION_FAILURE:
                    824:                
                    825:                /* Extraction failed */
                    826:                
                    827:                bInProgress = FALSE;
                    828: 
                    829:                NormalCursor ();
                    830: 
                    831:                StatusMessage (hCurPage, "EXTRACTION_FAILED");
                    832: 
                    833:                UpdateProgressBarProc(0);
                    834: 
                    835:                Error ("EXTRACTION_FAILED");
                    836: 
                    837:                nCurPageNo = EXTRACTION_OPTIONS_PAGE;
                    838:                LoadPage (hwndDlg, nCurPageNo);
                    839:                return 1;
                    840: 
                    841:        case WM_CLOSE:
1.1.1.3   root      842: 
1.1       root      843:                if (bInProgress)
                    844:                {
                    845:                        NormalCursor();
                    846:                        if (AskNoYes("CONFIRM_EXIT_UNIVERSAL") == IDNO)
                    847:                        {
                    848:                                return 1;
                    849:                        }
                    850:                        WaitCursor ();
                    851:                }
                    852: 
1.1.1.3   root      853:                if (bRestartRequired)
                    854:                {
1.1.1.4 ! root      855:                        if (AskWarnYesNo ("TC_INSTALLER_REQUIRING_RESTART") == IDYES)
1.1.1.3   root      856:                        {
                    857:                                RestartComputer();
                    858:                        }
                    859:                        return 1;
                    860:                }
1.1       root      861: 
                    862:                if (bOpenContainingFolder && bExtractOnly && bExtractionSuccessful)
                    863:                        ShellExecute (NULL, "open", WizardDestExtractPath, NULL, NULL, SW_SHOWNORMAL);
                    864: 
                    865:                EndDialog (hwndDlg, IDCANCEL);
                    866:                return 1;
                    867:        }
                    868: 
                    869:        return 0;
                    870: }
                    871: 
                    872: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.