Add animated progress bar and status labels during printer installation
Switch progress bar to marquee (animated) mode during post-install steps so users know the installer is working and not frozen. Status label updates at each step: legacy cleanup, driver staging, spooler restarts, port creation, and per-printer install/remove. Restores normal filled bar on completion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -874,6 +874,18 @@ begin
|
||||
Sleep(2000);
|
||||
end;
|
||||
|
||||
// ─── Progress helpers ────────────────────────────────────────────────────────
|
||||
|
||||
// Switch the wizard progress bar to marquee (animated) mode and update the
|
||||
// status label so the user knows what is happening during the post-install phase.
|
||||
procedure SetStatus(const Msg: String);
|
||||
begin
|
||||
WizardForm.ProgressGauge.Style := pbstMarquee;
|
||||
WizardForm.StatusLabel.Caption := Msg;
|
||||
WizardForm.FileNameLabel.Caption := '';
|
||||
Application.ProcessMessages;
|
||||
end;
|
||||
|
||||
// ─── Main installation ───────────────────────────────────────────────────────
|
||||
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
@@ -912,6 +924,7 @@ begin
|
||||
LogPath := LogDir + '\printer_install.log';
|
||||
|
||||
// ── Step 0: Remove legacy printers from old print servers ────────────────
|
||||
SetStatus('Removing legacy printers...');
|
||||
CleanedCount := CleanupLegacyPrinters();
|
||||
|
||||
IsX64 := Is64BitInstallMode;
|
||||
@@ -951,6 +964,7 @@ begin
|
||||
NeedSpoolerRestart := False;
|
||||
|
||||
// ── Step 1: Stage drivers with pnputil ──────────────────────────────────
|
||||
SetStatus('Staging printer drivers...');
|
||||
AddLog('Step 1: Staging printer drivers...');
|
||||
|
||||
if HasHP then
|
||||
@@ -1007,12 +1021,14 @@ begin
|
||||
// ── Step 2: Restart spooler to register staged drivers ──────────────────
|
||||
if NeedSpoolerRestart then
|
||||
begin
|
||||
SetStatus('Restarting print spooler...');
|
||||
AddLog('Step 2: Restarting print spooler to register staged drivers...');
|
||||
RestartSpooler();
|
||||
AddLog(' Spooler restarted');
|
||||
end;
|
||||
|
||||
// ── Step 3: Create TCP/IP ports ──────────────────────────────────────────
|
||||
SetStatus('Creating printer ports...');
|
||||
AddLog('Step 3: Creating printer ports...');
|
||||
|
||||
for I := 0 to GetArrayLength(PrinterDataArray) - 1 do
|
||||
@@ -1066,6 +1082,7 @@ begin
|
||||
|
||||
// ── Step 5: Restart spooler before printer changes to ensure all ports
|
||||
// and drivers are fully loaded in the live spooler session ──────
|
||||
SetStatus('Restarting print spooler...');
|
||||
AddLog('Step 5: Restarting spooler before printer installation...');
|
||||
RestartSpooler();
|
||||
AddLog(' Spooler restarted');
|
||||
@@ -1083,6 +1100,7 @@ begin
|
||||
// Remove: currently installed but now unchecked
|
||||
if PrinterDataArray[I].IsInstalled and (not PrinterSelectionPage.Values[I]) then
|
||||
begin
|
||||
SetStatus('Removing: ' + PrinterDataArray[I].PrinterName);
|
||||
AddLog('Removing: ' + PrinterDataArray[I].PrinterName);
|
||||
if RemoveNetworkPrinter(PrinterDataArray[I].PrinterName) then
|
||||
begin
|
||||
@@ -1099,6 +1117,7 @@ begin
|
||||
// Install: not installed but now checked
|
||||
else if (not PrinterDataArray[I].IsInstalled) and PrinterSelectionPage.Values[I] then
|
||||
begin
|
||||
SetStatus('Installing: ' + PrinterDataArray[I].PrinterName);
|
||||
AddLog('Installing: ' + PrinterDataArray[I].PrinterName);
|
||||
|
||||
if PrinterDataArray[I].Vendor = 'HP' then
|
||||
@@ -1173,6 +1192,12 @@ begin
|
||||
SetDefaultPrinterAllUsers(DefaultPrinter);
|
||||
end;
|
||||
|
||||
// Restore progress bar to normal completed state
|
||||
WizardForm.ProgressGauge.Style := pbstNormal;
|
||||
WizardForm.ProgressGauge.Position := WizardForm.ProgressGauge.Max;
|
||||
WizardForm.StatusLabel.Caption := 'Installation complete.';
|
||||
Application.ProcessMessages;
|
||||
|
||||
// Save log
|
||||
InstallLog.SaveToFile(LogPath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user