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

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
        !             8:  by the TrueCrypt License 2.4 the full text of which is contained in the
        !             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: 
        !            49: void localcleanup (void)
        !            50: {
        !            51:        /* Delete buffered bitmaps (if any) */
        !            52:        if (hbmWizardBitmapRescaled != NULL)
        !            53:        {
        !            54:                DeleteObject ((HGDIOBJ) hbmWizardBitmapRescaled);
        !            55:                hbmWizardBitmapRescaled = NULL;
        !            56:        }
        !            57: 
        !            58:        /* Cleanup common code resources */
        !            59:        cleanup ();
        !            60: }
        !            61: 
        !            62: static void InitWizardDestInstallPath (void)
        !            63: {
        !            64: 
        !            65:        if (strlen (WizardDestInstallPath) < 2)
        !            66:        {
        !            67:                strcpy (WizardDestInstallPath, InstallationPath);
        !            68:                if (WizardDestInstallPath [strlen (WizardDestInstallPath) - 1] != '\\')
        !            69:                {
        !            70:                        strcat (WizardDestInstallPath, "\\");
        !            71:                }
        !            72:        }
        !            73: }
        !            74: 
        !            75: void LoadPage (HWND hwndDlg, int nPageNo)
        !            76: {
        !            77:        RECT rD, rW;
        !            78: 
        !            79:        if (hCurPage != NULL)
        !            80:        {
        !            81:                DestroyWindow (hCurPage);
        !            82:        }
        !            83: 
        !            84:        GetWindowRect (GetDlgItem (hwndDlg, IDC_POS_BOX), &rW);
        !            85: 
        !            86:        nCurPageNo = nPageNo;
        !            87: 
        !            88:        switch (nPageNo)
        !            89:        {
        !            90:        case INTRO_PAGE:
        !            91:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INTRO_PAGE_DLG), hwndDlg,
        !            92:                                         (DLGPROC) PageDialogProc);
        !            93:                break;
        !            94: 
        !            95:        case WIZARD_MODE_PAGE:
        !            96:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_WIZARD_MODE_PAGE_DLG), hwndDlg,
        !            97:                                         (DLGPROC) PageDialogProc);
        !            98:                break;
        !            99: 
        !           100:        case INSTALL_OPTIONS_PAGE:
        !           101:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_INSTALL_OPTIONS_PAGE_DLG), hwndDlg,
        !           102:                                         (DLGPROC) PageDialogProc);
        !           103:                break;
        !           104: 
        !           105:        case INSTALL_PROGRESS_PAGE:
        !           106:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PROGRESS_PAGE_DLG), hwndDlg,
        !           107:                                         (DLGPROC) PageDialogProc);
        !           108:                break;
        !           109: 
        !           110:        case EXTRACTION_OPTIONS_PAGE:
        !           111:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_EXTRACTION_OPTIONS_PAGE_DLG), hwndDlg,
        !           112:                                         (DLGPROC) PageDialogProc);
        !           113:                break;
        !           114: 
        !           115:        case EXTRACTION_PROGRESS_PAGE:
        !           116:                hCurPage = CreateDialogW (hInst, MAKEINTRESOURCEW (IDD_PROGRESS_PAGE_DLG), hwndDlg,
        !           117:                                         (DLGPROC) PageDialogProc);
        !           118:                break;
        !           119:        }
        !           120: 
        !           121:        rD.left = 15;
        !           122:        rD.top = 45;
        !           123:        rD.right = 0;
        !           124:        rD.bottom = 0;
        !           125:        MapDialogRect (hwndDlg, &rD);
        !           126: 
        !           127:        if (hCurPage != NULL)
        !           128:        {
        !           129:                MoveWindow (hCurPage, rD.left, rD.top, rW.right - rW.left, rW.bottom - rW.top, TRUE);
        !           130:                ShowWindow (hCurPage, SW_SHOWNORMAL);
        !           131:        }
        !           132: 
        !           133:        /* Refresh the graphics (white background of some texts, etc.) */
        !           134:        RefreshUIGFX ();
        !           135: }
        !           136: 
        !           137: 
        !           138: /* Except in response to the WM_INITDIALOG message, the dialog box procedure
        !           139:    should return nonzero if it processes the message, and zero if it does
        !           140:    not. - see DialogProc */
        !           141: BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
        !           142: {
        !           143:        static char PageDebugId[128];
        !           144:        WORD lw = LOWORD (wParam);
        !           145:        WORD hw = HIWORD (wParam);
        !           146: 
        !           147:        hCurPage = hwndDlg;
        !           148: 
        !           149:        switch (uMsg)
        !           150:        {
        !           151:        case WM_INITDIALOG:
        !           152:                LocalizeDialog (hwndDlg, "IDD_INSTL_DLG");
        !           153: 
        !           154:                sprintf (PageDebugId, "SETUP_WIZARD_PAGE_%d", nCurPageNo);
        !           155:                LastDialogId = PageDebugId;
        !           156: 
        !           157:                switch (nCurPageNo)
        !           158:                {
        !           159:                case INTRO_PAGE:
        !           160:                        {
        !           161:                                char *licenseText = NULL;
        !           162: 
        !           163:                                licenseText = GetLegalNotices ();
        !           164:                                if (licenseText != NULL)
        !           165:                                {
        !           166:                                        SetWindowText (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), licenseText);
        !           167:                                        free (licenseText);
        !           168:                                }
        !           169:                                else
        !           170:                                {
        !           171:                                        Error("CANNOT_DISPLAY_LICENSE");
        !           172:                                        PostMessage (MainDlg, WM_CLOSE, 0, 0);
        !           173:                                }
        !           174: 
        !           175:                                /* Some of the following texts cannot be localized by third parties for legal reasons. */
        !           176: 
        !           177:                                CheckButton (GetDlgItem (hwndDlg, bLicenseAccepted ? IDC_AGREE : IDC_DISAGREE));
        !           178: 
        !           179:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), L"License Agreement");
        !           180:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), L"You must accept this license agreement before you can use, extract, or install TrueCrypt.");
        !           181:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), L"IMPORTANT: By selecting the first option below and clicking Accept, you accept and agree to be bound by these license terms. Click the 'arrow down' icon to see the rest of the license.");
        !           182:                                //SendMessage (GetDlgItem (hwndDlg, IDC_BOX_HELP), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
        !           183: 
        !           184:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_AGREE), L"I a&ccept and agree to be bound by all of the terms of the license agreement");
        !           185:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_DISAGREE), L"I &do not accept the terms of the license agreement");
        !           186: 
        !           187:                                //SendMessage (GetDlgItem (hwndDlg, IDC_AGREE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
        !           188:                                //SendMessage (GetDlgItem (hwndDlg, IDC_DISAGREE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
        !           189: 
        !           190:                                EnableWindow (GetDlgItem (hwndDlg, IDC_AGREE), TRUE);
        !           191:                                EnableWindow (GetDlgItem (hwndDlg, IDC_DISAGREE), TRUE);
        !           192: 
        !           193:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), L"&Accept");        // Cannot be localized by third parties for legal reasons.
        !           194:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
        !           195:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
        !           196: 
        !           197:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), bLicenseAccepted);
        !           198:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
        !           199:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), bLicenseAccepted);
        !           200:                        }
        !           201:                        return 1;
        !           202: 
        !           203:                case WIZARD_MODE_PAGE:
        !           204: 
        !           205:                        if (bRepairMode)
        !           206:                        {
        !           207:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), GetString ("REPAIR_REINSTALL"));
        !           208:                                bExtractOnly = FALSE;
        !           209:                        }
        !           210: 
        !           211:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_MODE_TITLE"));
        !           212:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_MODE_INFO"));
        !           213: 
        !           214:                        SendMessage (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
        !           215:                        SendMessage (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_EXTRACT_ONLY), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
        !           216: 
        !           217:                        CheckButton (GetDlgItem (hwndDlg, bExtractOnly ? IDC_WIZARD_MODE_EXTRACT_ONLY : IDC_WIZARD_MODE_INSTALL));
        !           218: 
        !           219:                        SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("SETUP_MODE_HELP_EXTRACT"));
        !           220: 
        !           221:                        if (!bRepairMode)
        !           222:                                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP2), GetString ("SETUP_MODE_HELP_INSTALL"));
        !           223: 
        !           224:                        EnableWindow (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_EXTRACT_ONLY), !bRepairMode);
        !           225:                        EnableWindow (GetDlgItem (hwndDlg, IDC_BOX_HELP), !bRepairMode);
        !           226:                        EnableWindow (GetDlgItem (hwndDlg, IDC_WIZARD_MODE_INSTALL), TRUE);
        !           227: 
        !           228:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
        !           229:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
        !           230:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDCANCEL), GetString ("CANCEL"));
        !           231:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
        !           232:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
        !           233: 
        !           234:                        return 1;
        !           235: 
        !           236:                case EXTRACTION_OPTIONS_PAGE:
        !           237: 
        !           238:                        if (strlen(WizardDestExtractPath) < 2)
        !           239:                        { 
        !           240:                                strcpy (WizardDestExtractPath, SetupFilesDir);
        !           241:                                strncat (WizardDestExtractPath, "TrueCrypt\\", sizeof (WizardDestExtractPath) - strlen (WizardDestExtractPath) - 1);
        !           242:                        }
        !           243: 
        !           244:                        SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
        !           245: 
        !           246:                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
        !           247: 
        !           248:                        SetCheckBox (hwndDlg, IDC_OPEN_CONTAINING_FOLDER, bOpenContainingFolder);
        !           249: 
        !           250:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("EXTRACTION_OPTIONS_TITLE"));
        !           251:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("EXTRACTION_OPTIONS_INFO"));
        !           252:                        SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION"));
        !           253: 
        !           254:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("EXTRACT"));
        !           255:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
        !           256:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
        !           257:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
        !           258:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
        !           259: 
        !           260:                        return 1;
        !           261: 
        !           262:                case EXTRACTION_PROGRESS_PAGE:
        !           263: 
        !           264:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("EXTRACTING_VERB"));
        !           265:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("EXTRACTION_PROGRESS_INFO"));
        !           266:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
        !           267: 
        !           268:                        if (bStartExtraction)
        !           269:                        {
        !           270:                                /* Start extraction */
        !           271: 
        !           272:                                LastDialogId = "EXTRACTION_IN_PROGRESS";
        !           273: 
        !           274:                                WaitCursor ();
        !           275: 
        !           276:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
        !           277:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
        !           278:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
        !           279:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
        !           280: 
        !           281:                                if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
        !           282:                                        strcat (WizardDestExtractPath, "\\");
        !           283: 
        !           284:                                strcpy (DestExtractPath, WizardDestExtractPath);
        !           285: 
        !           286:                                InitProgressBar ();
        !           287: 
        !           288:                                bInProgress = TRUE;
        !           289:                                bStartExtraction = FALSE;
        !           290: 
        !           291:                                _beginthread (ExtractAllFilesThread, 16384, (void *) hwndDlg);
        !           292:                        }
        !           293:                        else
        !           294:                        {
        !           295:                                NormalCursor ();
        !           296: 
        !           297:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
        !           298:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
        !           299:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
        !           300:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
        !           301:                        }
        !           302: 
        !           303:                        return 1;
        !           304: 
        !           305:                case INSTALL_OPTIONS_PAGE:
        !           306: 
        !           307:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_OPTIONS_TITLE"));
        !           308:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_OPTIONS_INFO"));
        !           309:                        SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION"));
        !           310: 
        !           311:                        InitWizardDestInstallPath ();
        !           312: 
        !           313:                        SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0);
        !           314: 
        !           315:                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
        !           316: 
        !           317:                        // System Restore
        !           318:                        SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, bSystemRestore);
        !           319:                        if (SystemRestoreDll == 0)
        !           320:                        {
        !           321:                                SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, FALSE);
        !           322:                                EnableWindow (GetDlgItem (hwndDlg, IDC_SYSTEM_RESTORE), FALSE);
        !           323:                        }
        !           324: 
        !           325:                        SetCheckBox (hwndDlg, IDC_ALL_USERS, bForAllUsers);
        !           326:                        SetCheckBox (hwndDlg, IDC_FILE_TYPE, bRegisterFileExt);
        !           327:                        SetCheckBox (hwndDlg, IDC_PROG_GROUP, bAddToStartMenu);
        !           328:                        SetCheckBox (hwndDlg, IDC_DESKTOP_ICON, bDesktopIcon);
        !           329: 
        !           330:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("INSTALL"));
        !           331:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
        !           332: 
        !           333:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
        !           334:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
        !           335:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
        !           336:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
        !           337: 
        !           338:                        return 1;
        !           339: 
        !           340:                case INSTALL_PROGRESS_PAGE:
        !           341: 
        !           342:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_PROGRESS_TITLE"));
        !           343:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_PROGRESS_INFO"));
        !           344:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
        !           345:                        SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
        !           346: 
        !           347:                        if (bStartInstall)
        !           348:                        {
        !           349:                                /* Start install */
        !           350: 
        !           351:                                LastDialogId = "INSTALL_IN_PROGRESS";
        !           352: 
        !           353:                                SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
        !           354: 
        !           355:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE);
        !           356:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
        !           357:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE);
        !           358:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), FALSE);
        !           359: 
        !           360:                                InitProgressBar ();
        !           361: 
        !           362:                                if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
        !           363:                                        strcat (WizardDestInstallPath, "\\");
        !           364: 
        !           365:                                strcpy (InstallationPath, WizardDestInstallPath);
        !           366: 
        !           367:                                WaitCursor ();
        !           368: 
        !           369:                                bInProgress = TRUE;
        !           370:                                bStartInstall = FALSE;
        !           371: 
        !           372:                                _beginthread (DoInstall, 16384, (void *) hwndDlg);
        !           373:                        }
        !           374:                        else
        !           375:                        {
        !           376:                                NormalCursor ();
        !           377: 
        !           378:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE);
        !           379:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
        !           380:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE);
        !           381:                                EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE);
        !           382: 
        !           383:                        }
        !           384: 
        !           385:                        return 1;
        !           386: 
        !           387:                }
        !           388:                return 0;
        !           389: 
        !           390:        case WM_HELP:
        !           391:                if (bLicenseAccepted)
        !           392:                        OpenPageHelp (GetParent (hwndDlg), nCurPageNo);
        !           393: 
        !           394:                return 1;
        !           395: 
        !           396:        case TC_APPMSG_LOAD_LICENSE:
        !           397:                {
        !           398:                        char *licenseText = NULL;
        !           399:                        licenseText = GetLegalNotices ();
        !           400:                        if (licenseText != NULL)
        !           401:                        {
        !           402:                                SetWindowText (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), licenseText);
        !           403:                                free (licenseText);
        !           404:                        }
        !           405:                        else
        !           406:                        {
        !           407:                                Error("CANNOT_DISPLAY_LICENSE");
        !           408:                                PostMessage (MainDlg, WM_CLOSE, 0, 0);
        !           409:                        }
        !           410:                }
        !           411:                return 1;
        !           412: 
        !           413: 
        !           414:        case WM_COMMAND:
        !           415: 
        !           416:                if (lw == IDC_DISAGREE && nCurPageNo == INTRO_PAGE)
        !           417:                {
        !           418:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE);
        !           419:                        return 1;
        !           420:                }
        !           421: 
        !           422:                if (lw == IDC_AGREE && nCurPageNo == INTRO_PAGE)
        !           423:                {
        !           424:                        EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
        !           425:                        return 1;
        !           426:                }
        !           427: 
        !           428:                if (lw == IDC_WIZARD_MODE_EXTRACT_ONLY && nCurPageNo == WIZARD_MODE_PAGE)
        !           429:                {
        !           430:                        bExtractOnly = TRUE;
        !           431:                        return 1;
        !           432:                }
        !           433: 
        !           434:                if (lw == IDC_WIZARD_MODE_INSTALL && nCurPageNo == WIZARD_MODE_PAGE)
        !           435:                {
        !           436:                        bExtractOnly = FALSE;
        !           437:                        return 1;
        !           438:                }
        !           439: 
        !           440:                if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE && hw == EN_CHANGE )
        !           441:                {
        !           442:                        EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
        !           443:                        return 1;
        !           444:                }
        !           445: 
        !           446:                if ( nCurPageNo == INSTALL_OPTIONS_PAGE && hw == EN_CHANGE )
        !           447:                {
        !           448:                        EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
        !           449:                        return 1;
        !           450:                }
        !           451: 
        !           452:                if (nCurPageNo == INTRO_PAGE && lw == IDC_LICENSE_TEXT && HIWORD (wParam) == EN_UPDATE)
        !           453:                {
        !           454:                        // License is read-only
        !           455:                        SendMessage (hwndDlg, TC_APPMSG_LOAD_LICENSE, 0, 0);
        !           456:                        return 1;
        !           457:                }
        !           458: 
        !           459:                if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE )
        !           460:                {
        !           461:                        switch (lw)
        !           462:                        {
        !           463:                        case IDC_BROWSE:
        !           464:                                if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestExtractPath))
        !           465:                                {
        !           466:                                        if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
        !           467:                                        {
        !           468:                                                strcat (WizardDestExtractPath, "\\");
        !           469:                                        }
        !           470:                                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
        !           471:                                }
        !           472:                                return 1;
        !           473: 
        !           474:                        case IDC_OPEN_CONTAINING_FOLDER:
        !           475:                                bOpenContainingFolder = IsButtonChecked (GetDlgItem (hCurPage, IDC_SYSTEM_RESTORE));
        !           476:                                return 1;
        !           477:                        }
        !           478:                }
        !           479: 
        !           480:                if ( nCurPageNo == INSTALL_OPTIONS_PAGE )
        !           481:                {
        !           482:                        switch (lw)
        !           483:                        {
        !           484:                        case IDC_BROWSE:
        !           485:                                if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestInstallPath))
        !           486:                                {
        !           487:                                        if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
        !           488:                                        {
        !           489:                                                strcat (WizardDestInstallPath, "\\");
        !           490:                                        }
        !           491:                                        SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
        !           492:                                }
        !           493:                                return 1;
        !           494: 
        !           495:                        case IDC_SYSTEM_RESTORE:
        !           496:                                bSystemRestore = IsButtonChecked (GetDlgItem (hCurPage, IDC_SYSTEM_RESTORE));
        !           497:                                return 1;
        !           498: 
        !           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:        if (lParam);            /* Remove unused parameter warning */
        !           574: 
        !           575:        switch (uMsg)
        !           576:        {
        !           577:        case WM_INITDIALOG:
        !           578:                {
        !           579:                        RECT rec;
        !           580: 
        !           581:                        GetModuleFileName (NULL, SelfFile, sizeof (SelfFile));
        !           582: 
        !           583:                        MainDlg = hwndDlg;
        !           584:                        InitDialog (hwndDlg);
        !           585:                        LocalizeDialog (hwndDlg, "IDD_INSTL_DLG");
        !           586:                        
        !           587:                        // Resize the bitmap if the user has a non-default DPI 
        !           588:                        if (ScreenDPI != USER_DEFAULT_SCREEN_DPI)
        !           589:                        {
        !           590:                                hbmWizardBitmapRescaled = RenderBitmap (MAKEINTRESOURCE (IDB_SETUP_WIZARD),
        !           591:                                        GetDlgItem (hwndDlg, IDC_BITMAP_SETUP_WIZARD),
        !           592:                                        0, 0, 0, 0, FALSE, TRUE);
        !           593:                        }
        !           594: 
        !           595:                        // Gfx area background (must not keep aspect ratio; must retain Windows-imposed distortion)
        !           596:                        GetClientRect (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_GFX_AREA), &rec);
        !           597:                        SetWindowPos (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_BKG), HWND_TOP, 0, 0, rec.right, rec.bottom, SWP_NOMOVE);
        !           598: 
        !           599:                        nPbar = IDC_PROGRESS_BAR;
        !           600: 
        !           601:                        SendMessage (GetDlgItem (hwndDlg, IDC_BOX_TITLE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
        !           602: 
        !           603:                        SetWindowTextW (hwndDlg, lpszTitle);
        !           604: 
        !           605:                        if (bDevm)
        !           606:                        {
        !           607:                                InitWizardDestInstallPath ();
        !           608:                                bSystemRestore = FALSE;
        !           609:                                bRegisterFileExt = FALSE;
        !           610:                                bAddToStartMenu = FALSE;
        !           611:                                bDesktopIcon = TRUE;
        !           612:                                bLicenseAccepted = TRUE;
        !           613:                                bStartInstall = TRUE;
        !           614:                                LoadPage (hwndDlg, INSTALL_PROGRESS_PAGE);
        !           615:                        }
        !           616:                        else
        !           617:                                LoadPage (hwndDlg, INTRO_PAGE);
        !           618:                }
        !           619:                return 0;
        !           620: 
        !           621:        case WM_SYSCOMMAND:
        !           622:                if (lw == IDC_ABOUT)
        !           623:                {
        !           624:                        if (bLicenseAccepted)
        !           625:                                DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc);
        !           626: 
        !           627:                        return 1;
        !           628:                }
        !           629:                return 0;
        !           630: 
        !           631:        case WM_HELP:
        !           632:                if (bLicenseAccepted)
        !           633:                        OpenPageHelp (hwndDlg, nCurPageNo);
        !           634: 
        !           635:                return 1;
        !           636: 
        !           637:        case WM_COMMAND:
        !           638:                if (lw == IDHELP)
        !           639:                {
        !           640:                        if (bLicenseAccepted)
        !           641:                                OpenPageHelp (hwndDlg, nCurPageNo);
        !           642: 
        !           643:                        return 1;
        !           644:                }
        !           645:                if (lw == IDCANCEL)
        !           646:                {
        !           647:                        PostMessage (hwndDlg, WM_CLOSE, 0, 0);
        !           648:                        return 1;
        !           649:                }
        !           650:                if (lw == IDC_NEXT)
        !           651:                {
        !           652:                        if (nCurPageNo == INTRO_PAGE)
        !           653:                        {
        !           654:                                if (!IsButtonChecked (GetDlgItem (hCurPage, IDC_AGREE)))
        !           655:                                {
        !           656:                                        bLicenseAccepted = FALSE;
        !           657:                                        return 1;
        !           658:                                }
        !           659:                                bLicenseAccepted = TRUE;
        !           660:                                EnableWindow (GetDlgItem (hwndDlg, IDHELP), TRUE);
        !           661:                        }
        !           662: 
        !           663:                        else if (nCurPageNo == WIZARD_MODE_PAGE)
        !           664:                        {
        !           665:                                if (bExtractOnly = IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY)))
        !           666:                                {
        !           667:                                        nCurPageNo = EXTRACTION_OPTIONS_PAGE - 1;
        !           668:                                }
        !           669:                        }
        !           670: 
        !           671:                        else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
        !           672:                        {
        !           673:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
        !           674:                                bStartExtraction = TRUE;
        !           675:                        }
        !           676:                        
        !           677:                        else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
        !           678:                        {
        !           679:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
        !           680:                                bStartInstall = TRUE;
        !           681:                        }
        !           682: 
        !           683:                        else if (nCurPageNo == INSTALL_PROGRESS_PAGE)
        !           684:                        {
        !           685:                                PostMessage (hwndDlg, WM_CLOSE, 0, 0);
        !           686:                                return 1;
        !           687:                        }
        !           688: 
        !           689:                        else if (nCurPageNo == EXTRACTION_PROGRESS_PAGE)
        !           690:                        {
        !           691:                                PostMessage (hwndDlg, WM_CLOSE, 0, 0);
        !           692:                                return 1;
        !           693:                        }
        !           694: 
        !           695:                        LoadPage (hwndDlg, ++nCurPageNo);
        !           696: 
        !           697:                        return 1;
        !           698:                }
        !           699: 
        !           700:                if (lw == IDC_PREV)
        !           701:                {
        !           702:                        if (nCurPageNo == WIZARD_MODE_PAGE)
        !           703:                        {
        !           704:                                bExtractOnly = IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY));
        !           705:                        }
        !           706: 
        !           707:                        else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
        !           708:                        {
        !           709:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
        !           710:                                nCurPageNo = WIZARD_MODE_PAGE + 1;
        !           711:                        }
        !           712: 
        !           713:                        else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
        !           714:                        {
        !           715:                                GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
        !           716:                        }
        !           717: 
        !           718:                        LoadPage (hwndDlg, --nCurPageNo);
        !           719: 
        !           720:                        return 1;
        !           721:                }
        !           722: 
        !           723:                return 0;
        !           724: 
        !           725:        case WM_CTLCOLORSTATIC:
        !           726: 
        !           727:                /* This maintains the white background under the transparent-backround texts */
        !           728: 
        !           729:                SetBkMode ((HDC) wParam, TRANSPARENT);
        !           730:                return ((LONG) (HBRUSH) (GetStockObject (NULL_BRUSH)));
        !           731: 
        !           732:        case WM_ERASEBKGND:
        !           733:                return 0;
        !           734: 
        !           735:        case TC_APPMSG_INSTALL_SUCCESS:
        !           736:                
        !           737:                /* Installation completed successfully */
        !           738:                
        !           739:                bInProgress = FALSE;
        !           740: 
        !           741:                NormalCursor ();
        !           742: 
        !           743:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
        !           744:                EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
        !           745:                EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
        !           746:                EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
        !           747:                EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
        !           748: 
        !           749:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("SETUP_FINISHED_TITLE"));
        !           750:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString ("SETUP_FINISHED_INFO"));
        !           751: 
        !           752:                RefreshUIGFX ();
        !           753:                return 1;
        !           754: 
        !           755:        case TC_APPMSG_INSTALL_FAILURE:
        !           756:                
        !           757:                /* Extraction failed */
        !           758:                
        !           759:                bInProgress = FALSE;
        !           760: 
        !           761:                NormalCursor ();
        !           762: 
        !           763:                nCurPageNo = INSTALL_OPTIONS_PAGE;
        !           764:                LoadPage (hwndDlg, nCurPageNo);
        !           765:                return 1;
        !           766: 
        !           767:        case TC_APPMSG_EXTRACTION_SUCCESS:
        !           768:                
        !           769:                /* Extraction completed successfully */
        !           770: 
        !           771:                InvalidateRect (GetDlgItem (MainDlg, IDD_INSTL_DLG), NULL, TRUE);
        !           772: 
        !           773:                bInProgress = FALSE;
        !           774:                bExtractionSuccessful = TRUE;
        !           775: 
        !           776:                NormalCursor ();
        !           777: 
        !           778:                StatusMessage (hCurPage, "EXTRACTION_FINISHED_INFO");
        !           779: 
        !           780:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
        !           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 ("EXTRACTION_FINISHED_TITLE"));
        !           787:                SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString ("EXTRACTION_FINISHED_INFO"));
        !           788: 
        !           789:                RefreshUIGFX ();
        !           790:                UpdateProgressBarProc(100);
        !           791: 
        !           792:                Info ("EXTRACTION_FINISHED_INFO");
        !           793: 
        !           794:                return 1;
        !           795: 
        !           796:        case TC_APPMSG_EXTRACTION_FAILURE:
        !           797:                
        !           798:                /* Extraction failed */
        !           799:                
        !           800:                bInProgress = FALSE;
        !           801: 
        !           802:                NormalCursor ();
        !           803: 
        !           804:                StatusMessage (hCurPage, "EXTRACTION_FAILED");
        !           805: 
        !           806:                UpdateProgressBarProc(0);
        !           807: 
        !           808:                Error ("EXTRACTION_FAILED");
        !           809: 
        !           810:                nCurPageNo = EXTRACTION_OPTIONS_PAGE;
        !           811:                LoadPage (hwndDlg, nCurPageNo);
        !           812:                return 1;
        !           813: 
        !           814:        case WM_CLOSE:
        !           815:                if (bInProgress)
        !           816:                {
        !           817:                        NormalCursor();
        !           818:                        if (AskNoYes("CONFIRM_EXIT_UNIVERSAL") == IDNO)
        !           819:                        {
        !           820:                                return 1;
        !           821:                        }
        !           822:                        WaitCursor ();
        !           823:                }
        !           824: 
        !           825:                localcleanup();
        !           826: 
        !           827:                if (bOpenContainingFolder && bExtractOnly && bExtractionSuccessful)
        !           828:                        ShellExecute (NULL, "open", WizardDestExtractPath, NULL, NULL, SW_SHOWNORMAL);
        !           829: 
        !           830:                EndDialog (hwndDlg, IDCANCEL);
        !           831:                return 1;
        !           832:        }
        !           833: 
        !           834:        return 0;
        !           835: }
        !           836: 
        !           837: 

unix.superglobalmegacorp.com

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