var
SettingPanel: TPanel;
hBtn: TButton;
//iStartTime: Integer; //debug
iTimer, iRollInfo: Integer;
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; external 'KillTimer@user32.dll stdcall';
//function GetTickCount: DWORD; external 'GetTickCount@kernel32.dll stdcall'; //debug
procedure TimerProc(hwnd: HWND; uMsg: UINT; idEvent: UINT_PTR; dwTime: DWORD);
var
iLen, iStep: Integer;
begin
iLen := iRollInfo and $FFFF;
iStep := (iRollInfo and $FF0000) shr $10;
case iRollInfo shr $18 of
$0: begin
if SettingPanel.Left >= -iStep then
begin
KillTimer(0, iTimer);
hBtn.Enabled := True;
end;
SettingPanel.Left := SettingPanel.Left + iStep;
//WizardForm.Caption := 'time: ' + IntToStr(dwTime-iStartTime) + '; length: ' + IntToStr(SettingPanel.Left); //debug
end;
$1: begin
if SettingPanel.Left <= -iLen + iStep then
begin
KillTimer(0, iTimer);
hBtn.Enabled := True;
end;
SettingPanel.Left := SettingPanel.Left - iStep;
//WizardForm.Caption := 'time: ' + IntToStr(dwTime-iStartTime) + '; length: ' + IntToStr(SettingPanel.Left); //debug
end;
$2: begin
if SettingPanel.Top >= -iStep then
begin
KillTimer(0, iTimer);
hBtn.Enabled := True;
end;
SettingPanel.Top := SettingPanel.Top + iStep;
//WizardForm.Caption := 'time: ' + IntToStr(dwTime-iStartTime) + '; length: ' + IntToStr(SettingPanel.Top); //debug
end;
$3: begin
if SettingPanel.Top <= -iLen + iStep then
begin
KillTimer(0, iTimer);
hBtn.Enabled := True;
end;
SettingPanel.Top := SettingPanel.Top - iStep;
//WizardForm.Caption := 'time: ' + IntToStr(dwTime-iStartTime) + '; length: ' + IntToStr(SettingPanel.Top); //debug
end;
end;
end;
procedure RollControl(Ctrl: TControl; dwTime, dwFlag: DWORD);
// Ctrl : control
// dwTime : rolling time, ms
// dwFlag : roll type ($0 - left to right, $1 - right to left, $2 - top to bottom, $3 - bottom to top)
var
iLen, iStep: Integer;
iKoeff: Extended;
begin
iLen := (dwFlag shr $1 xor $1)*Ctrl.Width + (dwFlag shr $1)*Ctrl.Height;
repeat
iStep := iStep + 1;
iKoeff := (iStep * dwTime)/(iLen * 1000/64);
until iKoeff >= 1;
//
if iRollInfo = 0 then iRollInfo := (dwFlag shl $18) or (iStep shl $10) or iLen else iRollInfo := iRollInfo xor $1000000;
iTimer := SetTimer(0, 0, Trunc(iKoeff)*1000/64, CallbackAddr('TimerProc'));
end;
procedure HideShow(Sender: TObject);
begin
//iStartTime := GetTickCount; //debug
RollControl(SettingPanel, 1000, $2);
TButton(Sender).Enabled := False;
end;
procedure InitializeWizard();
begin
SettingPanel := TPanel.Create(WizardForm);
with SettingPanel do
begin
Parent := WizardForm;
SetBounds(ScaleX(0), ScaleY(-315), ScaleX(497), ScaleY(315));
ParentBackground := False;
end;
hBtn := TButton.Create(WizardForm);
with hBtn do
begin
OnClick := @HideShow;
SetBounds(ScaleX(40), ScaleY(327), ScaleX(75), ScaleY(25));
Caption := 'Show';
Parent := WizardForm;
end;
end;
[/SPOILER]
[SPOILER=2 пример]
[Setup]
AppName=My Program
AppVerName=My Program v 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
OutputDir=.
[Code]
var
SettingPanel : TPanel;
Flag : boolean;
Timer : LongWord;
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; external 'KillTimer@user32.dll stdcall';
procedure MyTimer;
begin
case Flag of
True :
begin
if SettingPanel.Top = 0 then
KillTimer(WizardForm.Handle, Timer);
if SettingPanel.Top < 0 then SettingPanel.Top := SettingPanel.Top + ScaleY(3);
end;
False :
begin
if SettingPanel.Top = ScaleY(-315) then
KillTimer(WizardForm.Handle, Timer);
if SettingPanel.Top > ScaleY(-315) then SettingPanel.Top := SettingPanel.Top - ScaleY(3);
end;
end;
end;
procedure HideShow(Sender: TObject);
begin
KillTimer(WizardForm.Handle, Timer);
Timer := SetTimer(WizardForm.Handle, 1, 5 , CallbackAddr('MyTimer'));
case Flag of
True : TButton(Sender).Caption:='Show';
False : TButton(Sender).Caption:='Hide';
end;
Flag:= not Flag;
end;
procedure InitializeWizard();
begin
Flag:= False;
SettingPanel := TPanel.Create(WizardForm);
with SettingPanel do
begin
Parent := WizardForm;
SetBounds(ScaleX(0),ScaleY(-315),ScaleX(497),ScaleY(313));
ParentBackground := False;
end;
with TButton.Create(WizardForm) do
begin
OnClick:= @HideShow;
SetBounds(ScaleX(40),ScaleY(327),ScaleX(75),ScaleY(25))
Caption:='Show';
Parent:= WizardForm;
end;
end;
[/SPOILER]
[SPOILER=3 пример]
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
[code]
const
GWL_EXSTYLE = (-20);
WS_EX_COMPOSITED = $2000000;
AW_HIDE = $10000;
AW_VER_POSITIVE = $4;
AW_VER_NEGATIVE = $8;
function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function GetWindowLong(Wnd: HWnd; Index: Integer): Longint; external 'GetWindowLongA@user32.dll stdcall';
function AnimateWindow(hwnd: HWND; dwTime, dwFlags: DWORD): BOOL; external 'AnimateWindow@user32.dll stdcall';
var
SettingPanel: TPanel;
procedure NewButton1Click(Sender: TObject);
begin
with SettingPanel do
begin
//временно отрубаем стиль WS_EX_COMPOSITED, а то AnimateWindow плавненько не отработает
SetWindowLong(WizardForm.Handle, GWL_EXSTYLE, GetWindowLong(WizardForm.Handle, GWL_EXSTYLE) xor WS_EX_COMPOSITED);
AnimateWindow(Handle, 1000, (AW_VER_POSITIVE * dword(not Visible)) or ((AW_HIDE or AW_VER_NEGATIVE) * dword(Visible)));
SetWindowLong(WizardForm.Handle, GWL_EXSTYLE, GetWindowLong(WizardForm.Handle, GWL_EXSTYLE) or WS_EX_COMPOSITED);
Visible := not Visible;
end;
end;
procedure InitializeWizard();
begin
SetWindowLong(WizardForm.Handle, GWL_EXSTYLE, GetWindowLong(WizardForm.Handle, GWL_EXSTYLE) or WS_EX_COMPOSITED);
SettingPanel := TPanel.Create(WizardForm);
with SettingPanel do
begin
Parent := WizardForm;
SetBounds(ScaleX(0), ScaleY(0), WizardForm.ClientWidth, WizardForm.OuterNotebook.ClientHeight);
Visible := False;
end;
with TNewButton.Create(WizardForm) do
begin
Parent := WizardForm;
SetBounds(ScaleX(40), ScaleY(327), ScaleX(75), ScaleY(25));
Caption := 'open';
OnClick := @NewButton1Click;
end;
end;
[/SPOILER]