Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Пользователь


Сообщения: 76
Благодарности: 1

Профиль | Отправить PM | Цитировать


вот рабочий пример
Код: Выделить весь код
[Setup]
AppName=ProgressBar
AppVerName=ProgressBar
OutputBaseFilename=ProgressBar
DefaultDirName=ProgressBar
OutputDir=userdocs:..\desktop
Uninstallable=no

[ Code]
function GetWindowLong(Wnd: HWnd; Index: Integer): Longint; external 'GetWindowLongA@user32.dll stdcall';
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function GetTickCount: DWord; external 'GetTickCount@kernel32 stdcall';
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord; external 'SetTimer@User32.dll stdcall';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; external 'KillTimer@User32.dll stdcall';

var
  ProgressBar: TNewProgressBar;
  Timer: LongWord;
  Done: Boolean;
  InitialTime: DWord;

procedure Install;
var
  ErrorCode: Integer;
begin
  if ShellExec('Open', 'Timeout.exe', '/T ' + IntToStr(10000 div 1000), '', SW_HIDE, ewWaitUntilTerminated, ErrorCode) then
  begin
    Done:=True;
  end;
end;

procedure UpdateProgressBar(HandleW, msg, idEvent, TimeSys: LongWord);
begin
  if Done then
  begin
    KillTimer(0, Timer);
    ProgressBar.Position:=ProgressBar.Max;
  end
    else
  begin
    ProgressBar.Position:=GetTickCount - InitialTime;
  end;
end;

procedure InitializeWizard;
begin
    WizardForm.OuterNotebook.SetBounds(ScaleX(0), ScaleY(0), ScaleX(0), ScaleY(0));

      ProgressBar:=TNewProgressBar.Create(WizardForm);
      ProgressBar.Parent:=WizardForm;
      ProgressBar.SetBounds(ScaleX(-1), ScaleY(250), ScaleX(500), ScaleY(30));
      ProgressBar.Max:=10000;
      
    SetWindowLong(ProgressBar.Handle, -20, GetWindowLong(ProgressBar.Handle, -20) or $2000000);
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID=wpInstalling then
  begin
    Timer:=SetTimer(0, 0, 50, CreateCallback(@UpdateProgressBar));
    InitialTime:=GetTickCount;
    Install;
  end
end;
только он вешает систему (перетащить форму невозможно). может есть у кого другой вариант замедления прогресс бара - как в случае выше вместо (ProgressPage) применить (I, Step, Wait) к TNewProgressBar или к WizardForm.ProgressGauge

тоесть переписать этот кусок кода
Код: Выделить весь код
procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssPostInstall  then
  begin
    Wait:=2000;
    Step:=5; 
    ProgressPage:=CreateOutputProgressPage(WizardForm.PageNameLabel.Caption, WizardForm.PageDescriptionLabel.Caption);
    ProgressPage.SetProgress(0, Wait);
    ProgressPage.Show;
    try

      for I := 0 to Wait div Step do
      begin

        ProgressPage.SetProgress(I * Step, Wait);
        Sleep(Step);
      end;
    finally
      ProgressPage.Hide;
      ProgressPage.Free;
    end;
  end;
end;
под TNewProgressBar

Последний раз редактировалось Beavimo, 30-06-2025 в 18:38.


Отправлено: 18:28, 30-06-2025 | #1126