📄 wizard.c
字号:
return 1;
}
if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE && hw == EN_CHANGE )
{
EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
return 1;
}
if ( nCurPageNo == INSTALL_OPTIONS_PAGE && hw == EN_CHANGE )
{
EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1));
return 1;
}
if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE )
{
switch (lw)
{
case IDC_BROWSE:
if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestExtractPath))
{
if (WizardDestExtractPath [strlen(WizardDestExtractPath)-1] != '\\')
{
strcat (WizardDestExtractPath, "\\");
}
SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath);
}
return 1;
case IDC_OPEN_CONTAINING_FOLDER:
bOpenContainingFolder = IsButtonChecked (GetDlgItem (hCurPage, IDC_OPEN_CONTAINING_FOLDER));
return 1;
}
}
if ( nCurPageNo == INSTALL_OPTIONS_PAGE )
{
switch (lw)
{
case IDC_BROWSE:
if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestInstallPath))
{
if (WizardDestInstallPath [strlen(WizardDestInstallPath)-1] != '\\')
{
strcat (WizardDestInstallPath, "\\");
}
SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath);
}
return 1;
case IDC_SYSTEM_RESTORE:
bSystemRestore = IsButtonChecked (GetDlgItem (hCurPage, IDC_SYSTEM_RESTORE));
return 1;
#if 0
case IDC_DISABLE_PAGING_FILES:
bDisableSwapFiles = IsButtonChecked (GetDlgItem (hCurPage, IDC_DISABLE_PAGING_FILES));
if (!bDisableSwapFiles
&& AskWarnNoYes("CONFIRM_NOT_DISABLING_SWAP_FILES") == IDNO)
{
bDisableSwapFiles = TRUE;
SetCheckBox (hwndDlg, IDC_DISABLE_PAGING_FILES, bDisableSwapFiles);
}
return 1;
#endif // 0
case IDC_ALL_USERS:
bForAllUsers = IsButtonChecked (GetDlgItem (hCurPage, IDC_ALL_USERS));
return 1;
case IDC_FILE_TYPE:
bRegisterFileExt = IsButtonChecked (GetDlgItem (hCurPage, IDC_FILE_TYPE));
return 1;
case IDC_PROG_GROUP:
bAddToStartMenu = IsButtonChecked (GetDlgItem (hCurPage, IDC_PROG_GROUP));
return 1;
case IDC_DESKTOP_ICON:
bDesktopIcon = IsButtonChecked (GetDlgItem (hCurPage, IDC_DESKTOP_ICON));
return 1;
}
}
return 0;
}
return 0;
}
void InitProgressBar (void)
{
HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
SendMessage (hProgressBar, PBM_SETRANGE32, 0, 100);
SendMessage (hProgressBar, PBM_SETSTEP, 1, 0);
InvalidateRect (hProgressBar, NULL, TRUE);
}
// Must always return TRUE
BOOL UpdateProgressBarProc (int nPercent)
{
HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
SendMessage (hProgressBar, PBM_SETPOS, (int) (100.0 * nPercent / 100), 0);
InvalidateRect (hProgressBar, NULL, TRUE);
ShowWindow(hProgressBar, SW_HIDE);
ShowWindow(hProgressBar, SW_SHOW);
// Prevent the IDC_LOG_WINDOW item from partially disappearing at higher DPIs
ShowWindow(GetDlgItem (hCurPage, IDC_LOG_WINDOW), SW_HIDE);
ShowWindow(GetDlgItem (hCurPage, IDC_LOG_WINDOW), SW_SHOW);
RefreshUIGFX();
return TRUE;
}
void RefreshUIGFX (void)
{
InvalidateRect (GetDlgItem (MainDlg, IDC_SETUP_WIZARD_BKG), NULL, TRUE);
InvalidateRect (GetDlgItem (MainDlg, IDC_BOX_TITLE), NULL, TRUE);
InvalidateRect (GetDlgItem (MainDlg, IDC_BOX_INFO), NULL, TRUE);
InvalidateRect (GetDlgItem (MainDlg, IDC_BITMAP_SETUP_WIZARD), NULL, TRUE);
InvalidateRect (GetDlgItem (MainDlg, IDC_HR), NULL, TRUE);
// Prevent these items from disappearing at higher DPIs
ShowWindow(GetDlgItem(MainDlg, IDC_HR), SW_HIDE);
ShowWindow(GetDlgItem(MainDlg, IDC_HR), SW_SHOW);
ShowWindow(GetDlgItem(MainDlg, IDC_HR_BOTTOM), SW_HIDE);
ShowWindow(GetDlgItem(MainDlg, IDC_HR_BOTTOM), SW_SHOW);
ShowWindow(GetDlgItem(MainDlg, IDC_BOX_INFO), SW_HIDE);
ShowWindow(GetDlgItem(MainDlg, IDC_BOX_INFO), SW_SHOW);
ShowWindow(GetDlgItem(MainDlg, IDC_BOX_TITLE), SW_HIDE);
ShowWindow(GetDlgItem(MainDlg, IDC_BOX_TITLE), SW_SHOW);
}
/* Except in response to the WM_INITDIALOG message, the dialog box procedure
should return nonzero if it processes the message, and zero if it does
not. - see DialogProc */
BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
WORD lw = LOWORD (wParam);
switch (uMsg)
{
case WM_INITDIALOG:
{
RECT rec;
GetModuleFileName (NULL, SelfFile, sizeof (SelfFile));
MainDlg = hwndDlg;
if (!CreateAppSetupMutex ())
AbortProcess ("TC_INSTALLER_IS_RUNNING");
InitDialog (hwndDlg);
LocalizeDialog (hwndDlg, "IDD_INSTL_DLG");
// Resize the bitmap if the user has a non-default DPI
if (ScreenDPI != USER_DEFAULT_SCREEN_DPI)
{
hbmWizardBitmapRescaled = RenderBitmap (MAKEINTRESOURCE (IDB_SETUP_WIZARD),
GetDlgItem (hwndDlg, IDC_BITMAP_SETUP_WIZARD),
0, 0, 0, 0, FALSE, TRUE);
}
// Gfx area background (must not keep aspect ratio; must retain Windows-imposed distortion)
GetClientRect (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_GFX_AREA), &rec);
SetWindowPos (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_BKG), HWND_TOP, 0, 0, rec.right, rec.bottom, SWP_NOMOVE);
nPbar = IDC_PROGRESS_BAR;
SendMessage (GetDlgItem (hwndDlg, IDC_BOX_TITLE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE);
SetWindowTextW (hwndDlg, lpszTitle);
if (bDevm)
{
InitWizardDestInstallPath ();
bSystemRestore = FALSE;
bRegisterFileExt = FALSE;
bAddToStartMenu = FALSE;
bDesktopIcon = TRUE;
bLicenseAccepted = TRUE;
bStartInstall = TRUE;
LoadPage (hwndDlg, INSTALL_PROGRESS_PAGE);
}
else
LoadPage (hwndDlg, INTRO_PAGE);
}
return 0;
case WM_SYSCOMMAND:
if (lw == IDC_ABOUT)
{
if (bLicenseAccepted)
DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc);
return 1;
}
return 0;
case WM_HELP:
if (bLicenseAccepted)
OpenPageHelp (hwndDlg, nCurPageNo);
return 1;
case WM_COMMAND:
if (lw == IDHELP)
{
if (bLicenseAccepted)
OpenPageHelp (hwndDlg, nCurPageNo);
return 1;
}
if (lw == IDCANCEL)
{
PostMessage (hwndDlg, WM_CLOSE, 0, 0);
return 1;
}
if (lw == IDC_NEXT)
{
if (nCurPageNo == INTRO_PAGE)
{
if (!IsButtonChecked (GetDlgItem (hCurPage, IDC_AGREE)))
{
bLicenseAccepted = FALSE;
return 1;
}
bLicenseAccepted = TRUE;
EnableWindow (GetDlgItem (hwndDlg, IDHELP), TRUE);
}
else if (nCurPageNo == WIZARD_MODE_PAGE)
{
if (IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY)))
{
if (IsUacSupported()
&& AskWarnYesNo ("TRAVELER_UAC_NOTE") == IDNO)
{
return 1;
}
bExtractOnly = TRUE;
nCurPageNo = EXTRACTION_OPTIONS_PAGE - 1;
}
}
else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
{
GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
bStartExtraction = TRUE;
}
else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
{
GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
bStartInstall = TRUE;
}
else if (nCurPageNo == INSTALL_PROGRESS_PAGE)
{
PostMessage (hwndDlg, WM_CLOSE, 0, 0);
return 1;
}
else if (nCurPageNo == EXTRACTION_PROGRESS_PAGE)
{
PostMessage (hwndDlg, WM_CLOSE, 0, 0);
return 1;
}
LoadPage (hwndDlg, ++nCurPageNo);
return 1;
}
if (lw == IDC_PREV)
{
if (nCurPageNo == WIZARD_MODE_PAGE)
{
bExtractOnly = IsButtonChecked (GetDlgItem (hCurPage, IDC_WIZARD_MODE_EXTRACT_ONLY));
}
else if (nCurPageNo == EXTRACTION_OPTIONS_PAGE)
{
GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestExtractPath, sizeof (WizardDestExtractPath));
nCurPageNo = WIZARD_MODE_PAGE + 1;
}
else if (nCurPageNo == INSTALL_OPTIONS_PAGE)
{
GetWindowText (GetDlgItem (hCurPage, IDC_DESTINATION), WizardDestInstallPath, sizeof (WizardDestInstallPath));
}
LoadPage (hwndDlg, --nCurPageNo);
return 1;
}
return 0;
case WM_CTLCOLORSTATIC:
/* This maintains the white background under the transparent-backround texts */
SetBkMode ((HDC) wParam, TRANSPARENT);
return ((LONG) (HBRUSH) (GetStockObject (NULL_BRUSH)));
case WM_ERASEBKGND:
return 0;
case TC_APPMSG_INSTALL_SUCCESS:
/* Installation completed successfully */
bInProgress = FALSE;
NormalCursor ();
SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString (bRestartRequired ? "RESTART" : "FINALIZE"));
EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("SETUP_FINISHED_TITLE"));
SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString (bRestartRequired ? "SETUP_FINISHED_INFO_RESTART_REQUIRED" : "SETUP_FINISHED_INFO"));
RefreshUIGFX ();
return 1;
case TC_APPMSG_INSTALL_FAILURE:
/* Extraction failed */
bInProgress = FALSE;
NormalCursor ();
nCurPageNo = INSTALL_OPTIONS_PAGE;
LoadPage (hwndDlg, nCurPageNo);
return 1;
case TC_APPMSG_EXTRACTION_SUCCESS:
/* Extraction completed successfully */
InvalidateRect (GetDlgItem (MainDlg, IDD_INSTL_DLG), NULL, TRUE);
bInProgress = FALSE;
bExtractionSuccessful = TRUE;
NormalCursor ();
StatusMessage (hCurPage, "EXTRACTION_FINISHED_INFO");
SetWindowTextW (GetDlgItem (hwndDlg, IDC_NEXT), GetString ("FINALIZE"));
EnableWindow (GetDlgItem (hwndDlg, IDC_PREV), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_NEXT), TRUE);
EnableWindow (GetDlgItem (hwndDlg, IDHELP), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDCANCEL), FALSE);
SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), GetString ("EXTRACTION_FINISHED_TITLE"));
SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_INFO), GetString ("EXTRACTION_FINISHED_INFO"));
RefreshUIGFX ();
UpdateProgressBarProc(100);
Info ("EXTRACTION_FINISHED_INFO");
return 1;
case TC_APPMSG_EXTRACTION_FAILURE:
/* Extraction failed */
bInProgress = FALSE;
NormalCursor ();
StatusMessage (hCurPage, "EXTRACTION_FAILED");
UpdateProgressBarProc(0);
Error ("EXTRACTION_FAILED");
nCurPageNo = EXTRACTION_OPTIONS_PAGE;
LoadPage (hwndDlg, nCurPageNo);
return 1;
case WM_CLOSE:
if (bInProgress)
{
NormalCursor();
if (AskNoYes("CONFIRM_EXIT_UNIVERSAL") == IDNO)
{
return 1;
}
WaitCursor ();
}
if (bRestartRequired)
{
if (AskWarnYesNo ("TC_INSTALLER_REQUIRING_RESTART") == IDYES)
{
RestartComputer();
}
return 1;
}
if (bOpenContainingFolder && bExtractOnly && bExtractionSuccessful)
ShellExecute (NULL, "open", WizardDestExtractPath, NULL, NULL, SW_SHOWNORMAL);
EndDialog (hwndDlg, IDCANCEL);
return 1;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -