This code from Bass Audio Library on/off Button does "Pause", how to change it to "Mute"?
What should I change?
const
BASS_SAMPLE_LOOP = 4;
BASS_ACTIVE_STOPPED = 0;
BASS_ACTIVE_PLAYING = 1;
BASS_ACTIVE_STALLED = 2;
BASS_ACTIVE_PAUSED = 3;
BASS_UNICODE = $80000000;
BASS_CONFIG_GVOL_STREAM = 5;
const
#ifndef UNICODE
EncodingFlag = 0;
#else
EncodingFlag = BASS_UNICODE;
#endif
type
HSTREAM = DWORD;
function BASS_Init(device: LongInt; freq, flags: DWORD;
win: HWND; clsid: Cardinal): BOOL;
external 'BASS_Init#files:bass.dll stdcall';
function BASS_StreamCreateFile(mem: BOOL; f: string; offset1: DWORD;
offset2: DWORD; length1: DWORD; length2: DWORD; flags: DWORD): HSTREAM;
external 'BASS_StreamCreateFile#files:bass.dll stdcall';
function BASS_Start: BOOL;
external 'BASS_Start#files:bass.dll stdcall';
function BASS_Pause: BOOL;
external 'BASS_Pause#files:bass.dll stdcall';
function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL;
external 'BASS_ChannelPlay#files:bass.dll stdcall';
function BASS_SetConfig(option: DWORD; value: DWORD ): BOOL;
external 'BASS_SetConfig#files:bass.dll stdcall';
function BASS_ChannelIsActive(handle: DWORD): DWORD;
external 'BASS_ChannelIsActive#files:bass.dll stdcall';
function BASS_Free: BOOL;
external 'BASS_Free#files:bass.dll stdcall';
var
SoundStream: HSTREAM;
SoundCtrlButton: TNewButton;
procedure SoundCtrlButtonClick(Sender: TObject);
begin
case BASS_ChannelIsActive(SoundStream) of
BASS_ACTIVE_PLAYING:
begin
if BASS_Pause then
SoundCtrlButton.Caption :=
ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOn}');
end;
BASS_ACTIVE_PAUSED:
begin
if BASS_Start then
SoundCtrlButton.Caption :=
ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}');
end;
end;
end;
procedure InitializeWizard;
begin
ExtractTemporaryFile('tune.mp3');
if BASS_Init(-1, 44100, 0, 0, 0) then
begin
SoundStream := BASS_StreamCreateFile(False,
ExpandConstant('{tmp}\tune.mp3'), 0, 0, 0, 0,
EncodingFlag or BASS_SAMPLE_LOOP);
BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500);
BASS_ChannelPlay(SoundStream, False);
SoundCtrlButton := TNewButton.Create(WizardForm);
SoundCtrlButton.Parent := WizardForm;
SoundCtrlButton.Left := 8;
SoundCtrlButton.Top := WizardForm.ClientHeight -
SoundCtrlButton.Height - 8;
SoundCtrlButton.Width := 40;
SoundCtrlButton.Caption :=
ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}');
SoundCtrlButton.OnClick := #SoundCtrlButtonClick;
end;
end;
procedure DeinitializeSetup;
begin
BASS_Free;
end;
To control volume level, use the BASS_SetConfig with option set to:
BASS_CONFIG_GVOL_STREAM for "stream", created e.g. using the BASS_StreamCreateFile;
BASS_CONFIG_GVOL_MUSIC for "music", created e.g. using BASS_MusicLoad.
The SoundCtrlButtonClick is replacement for the pause/resume implementation of the same-named function from your question.
var
Muted: Boolean;
procedure SoundCtrlButtonClick(Sender: TObject);
begin
if not Muted then
begin
if BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 0) then
begin
SoundCtrlButton.Caption := 'unmute';
Muted := True;
end;
end
else
begin
if BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500) then
begin
SoundCtrlButton.Caption := 'mute';
Muted := False;
end;
end;
end;
Related
Thanks to this article posted at Add audio when Splash Screen starts on Inno Setup
the code work like a charm, I just wanted to know what to do so that the music of my installer is only played once.
I don´t want it to be repeated continuously.
Thanks in advance...
Code im using
[Code]
const
BASS_SAMPLE_LOOP = 4;
BASS_UNICODE = $80000000;
BASS_CONFIG_GVOL_STREAM = 5;
const
#ifndef UNICODE
EncodingFlag = 0;
#else
EncodingFlag = BASS_UNICODE;
#endif
type
HSTREAM = DWORD;
function BASS_Init(device: LongInt; freq, flags: DWORD;
win: HWND; clsid: Cardinal): BOOL;
external 'BASS_Init#files:bass.dll stdcall';
function BASS_StreamCreateFile(mem: BOOL; f: string; offset1: DWORD;
offset2: DWORD; length1: DWORD; length2: DWORD; flags: DWORD): HSTREAM;
external 'BASS_StreamCreateFile#files:bass.dll stdcall';
function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL;
external 'BASS_ChannelPlay#files:bass.dll stdcall';
function BASS_SetConfig(option: DWORD; value: DWORD ): BOOL;
external 'BASS_SetConfig#files:bass.dll stdcall';
function BASS_Free: BOOL;
external 'BASS_Free#files:bass.dll stdcall';
procedure InitializeWizard;
var
StreamHandle: HSTREAM;
begin
ExtractTemporaryFile('AudioFile.mp3');
if BASS_Init(-1, 44100, 0, 0, 0) then
begin
StreamHandle := BASS_StreamCreateFile(False,
ExpandConstant('{tmp}\AudioFile.mp3'), 0, 0, 0, 0,
EncodingFlag or BASS_SAMPLE_LOOP);
BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500);
BASS_ChannelPlay(StreamHandle, False);
end;
end;
procedure DeinitializeSetup;
begin
BASS_Free;
end;
When I choose .mp3 file, it will play when launching setup.exe but when I change it to .xm or .s3m, it doesn't play
[Setup]
AppName=Bass Audio Project
AppVersion=1.0
DefaultDirName={pf}\Bass Audio Project
[Files]
Source: "Bass.dll"; Flags: dontcopy
Source: "tune.xm"; Flags: dontcopy
[CustomMessages]
SoundCtrlButtonCaptionSoundOn=Play
SoundCtrlButtonCaptionSoundOff=Mute
[Code]
const
BASS_SAMPLE_LOOP = 4;
BASS_ACTIVE_STOPPED = 0;
BASS_ACTIVE_PLAYING = 1;
BASS_ACTIVE_STALLED = 2;
BASS_ACTIVE_PAUSED = 3;
BASS_UNICODE = $80000000;
BASS_CONFIG_GVOL_STREAM = 5;
const
#ifndef UNICODE
EncodingFlag = 0;
#else
EncodingFlag = BASS_UNICODE;
#endif
type
HSTREAM = DWORD;
function BASS_Init(device: LongInt; freq, flags: DWORD;
win: HWND; clsid: Cardinal): BOOL;
external 'BASS_Init#files:bass.dll stdcall';
function BASS_StreamCreateFile(mem: BOOL; f: string; offset1: DWORD;
offset2: DWORD; length1: DWORD; length2: DWORD; flags: DWORD): HSTREAM;
external 'BASS_StreamCreateFile#files:bass.dll stdcall';
function BASS_Start: BOOL;
external 'BASS_Start#files:bass.dll stdcall';
function BASS_Pause: BOOL;
external 'BASS_Pause#files:bass.dll stdcall';
function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL;
external 'BASS_ChannelPlay#files:bass.dll stdcall';
function BASS_SetConfig(option: DWORD; value: DWORD ): BOOL;
external 'BASS_SetConfig#files:bass.dll stdcall';
function BASS_ChannelIsActive(handle: DWORD): DWORD;
external 'BASS_ChannelIsActive#files:bass.dll stdcall';
function BASS_Free: BOOL;
external 'BASS_Free#files:bass.dll stdcall';
var
SoundStream: HSTREAM;
SoundCtrlButton: TNewButton;
Muted: Boolean;
procedure SoundCtrlButtonClick(Sender: TObject);
begin
if not Muted then
begin
if BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 0) then
begin
SoundCtrlButton.Caption := 'Play';
Muted := True;
end;
end
else
begin
if BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500) then
begin
SoundCtrlButton.Caption := 'Mute';
Muted := False;
end;
end;
end;
procedure InitializeWizard;
begin
ExtractTemporaryFile('tune.xm');
if BASS_Init(-1, 44100, 0, 0, 0) then
begin
SoundStream := BASS_StreamCreateFile(False,
ExpandConstant('{tmp}\tune.xm'), 0, 0, 0, 0,
EncodingFlag or BASS_SAMPLE_LOOP);
BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 2500);
BASS_ChannelPlay(SoundStream, False);
SoundCtrlButton := TNewButton.Create(WizardForm);
SoundCtrlButton.Parent := WizardForm;
SoundCtrlButton.Left := 8;
SoundCtrlButton.Top := WizardForm.ClientHeight -
SoundCtrlButton.Height - 8;
SoundCtrlButton.Width := 40;
SoundCtrlButton.Caption :=
ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}');
SoundCtrlButton.OnClick := #SoundCtrlButtonClick;
end;
end;
procedure DeinitializeSetup;
begin
BASS_Free;
end;
What should I do? I want to use to original file which is .xm or .s3m and not the converted one which is .mp3.
As seen on Un4seen, bass.dll supports .xm and .s3m.
Indeed, the BASS_StreamCreateFile returns 0 for both files.
And if you call BASS_ErrorGetCode afterwards, it returns 41 = BASS_ERROR_FILEFORM (unsupported file format).
function BASS_ErrorGetCode(): Integer;
external 'BASS_ErrorGetCode#files:bass.dll stdcall';
SoundStream := BASS_StreamCreateFile(...);
if SoundStream = 0 then
begin
Log(Format('Error playing file, error code = %d', [BASS_ErrorGetCode]));
end;
But as you correctly hinted, you should use the BASS_MusicLoad for MO3 / IT / XM / S3M / MTM / MOD / UMX formats.
type
HMUSIC = DWORD;
function BASS_MusicLoad(
mem: BOOL; f: string; offset: Int64; length, flags, freq: DWORD): HMUSIC;
external 'BASS_MusicLoad#files:bass.dll stdcall';
Replace the BASS_StreamCreateFile call with:
BASS_MusicLoad(
False, ExpandConstant('{tmp}\tune.xm'), 0, 0,
EncodingFlag or BASS_SAMPLE_LOOP, 0)
Semantically, your should also rename the SoundStream variable to Music or similar; and change its type to HMUSIC.
Help modify the time I am not getting much time is left and the elapsed time of installation is appearing on the page status has to appear on the page installing I got here on the site script time can someone check my script and point out the error The script I use isdone more time Sample image of what I want I am not able to post complete script.iss download link full
enter link description here
[Code]
////////////////////////////////////ISDONE///////////////////////////
const
PCFonFLY=true;
notPCFonFLY=false;
var
LabelPct1,LabelCurrFileName,LabelTime1,LabelTime2: TLabel; //Desativa - LabelTime3
ISDoneProgressBar1: TNewProgressBar;
MyCancelButton: TButton;
ISDoneCancel:integer;
ISDoneError:boolean;
PCFVer:double;
type
TCallback = function (OveralPct,CurrentPct:
integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:PAnsiChar): longword;
function WrapCallback(callback:TCallback; paramcount:integer):longword;external
'wrapcallback#files:ISDone.dll stdcall delayload';
function ISArcExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutPath,
ExtractedPath: AnsiString; DeleteInFile:boolean; Password, CfgFile, WorkPath:
AnsiString;
ExtractPCF: boolean ):boolean; external 'ISArcExtract#files:ISDone.dll stdcall
delayload';
function IS7ZipExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutPath:
AnsiString; DeleteInFile:boolean; Password: AnsiString):boolean; external
'IS7zipExtract#files:ISDone.dll stdcall delayload';
function ISRarExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutPath:
AnsiString; DeleteInFile:boolean; Password: AnsiString):boolean; external
'ISRarExtract#files:ISDone.dll stdcall delayload';
function ISPrecompExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutFile:
AnsiString; DeleteInFile:boolean):boolean; external 'ISPrecompExtract#files:ISDone.dll
stdcall delayload';
function ISSRepExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutFile:
AnsiString; DeleteInFile:boolean):boolean; external 'ISSrepExtract#files:ISDone.dll
stdcall delayload';
function ISxDeltaExtract(CurComponent:Cardinal; PctOfTotal:double;
minRAM,maxRAM:integer; InName, DiffFile, OutFile: AnsiString; DeleteInFile,
DeleteDiffFile:boolean):boolean; external 'ISxDeltaExtract#files:ISDone.dll stdcall
delayload';
function ISPackZIP(CurComponent:Cardinal; PctOfTotal:double; InName, OutFile:
AnsiString;ComprLvl:integer; DeleteInFile:boolean):boolean; external
'ISPackZIP#files:ISDone.dll stdcall delayload';
function ShowChangeDiskWindow(Text, DefaultPath, SearchFile:AnsiString):boolean;
external 'ShowChangeDiskWindow#files:ISDone.dll stdcall delayload';
function Exec2 (FileName, Param: PAnsiChar;Show:boolean):boolean; external
'Exec2#files:ISDone.dll stdcall delayload';
function ISFindFiles(CurComponent:Cardinal; FileMask:AnsiString; var
ColFiles:integer):integer; external 'ISFindFiles#files:ISDone.dll stdcall delayload';
function ISPickFilename(FindHandle:integer; OutPath:AnsiString; var CurIndex:integer;
DeleteInFile:boolean):boolean; external 'ISPickFilename#files:ISDone.dll stdcall
delayload';
function ISGetName(TypeStr:integer):PAnsichar; external 'ISGetName#files:ISDone.dll
stdcall delayload';
function ISFindFree(FindHandle:integer):boolean; external 'ISFindFree#files:ISDone.dll
stdcall delayload';
function ISExec(CurComponent:Cardinal; PctOfTotal,SpecifiedProcessTime:double;
ExeName,Parameters,TargetDir,OutputStr:AnsiString;Show:boolean):boolean; external
'ISExec#files:ISDone.dll stdcall delayload';
function SrepInit(TmpPath:PAnsiChar;VirtMem,MaxSave:Cardinal):boolean; external
'SrepInit#files:ISDone.dll stdcall delayload';
function PrecompInit(TmpPath:PAnsiChar;VirtMem:cardinal;PrecompVers:single):boolean;
external 'PrecompInit#files:ISDone.dll stdcall delayload';
function FileSearchInit(RecursiveSubDir:boolean):boolean; external
'FileSearchInit#files:ISDone.dll stdcall delayload';
function ISDoneInit(RecordFileName:AnsiString; TimeType,Comp1,Comp2,Comp3:Cardinal;
WinHandle, NeededMem:longint; callback:TCallback):boolean; external
'ISDoneInit#files:ISDone.dll stdcall';
function ISDoneStop:boolean; external 'ISDoneStop#files:ISDone.dll stdcall';
function ChangeLanguage(Language:AnsiString):boolean; external
'ChangeLanguage#files:ISDone.dll stdcall delayload';
function SuspendProc:boolean; external 'SuspendProc#files:ISDone.dll stdcall';
function ResumeProc:boolean; external 'ResumeProc#files:ISDone.dll stdcall';
function ProgressCallback(OveralPct,CurrentPct:
integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:PAnsiChar): longword;
begin
if OveralPct<=1000 then ISDoneProgressBar1.Position := OveralPct;
LabelPct1.Caption := IntToStr(OveralPct div 10)+'.'+chr(48 + OveralPct mod 10)+'%';
// LabelCurrFileName.Caption:='Instalando arquivos.. '+MinimizePathName(CurrentFile,
LabelCurrFileName.Font, LabelCurrFileName.Width-ScaleX(100));
LabelCurrFileName.Caption:=ExpandConstant('')+MinimizePathName(ExpandConstant('{app}\
')+CurrentFile, LabelCurrFileName.Font,WizardForm.FilenameLabel.Width);
LabelTime1.Caption:=ExpandConstant('{cm:ElapsedTime} ')+TimeStr2;
LabelTime2.Caption:=ExpandConstant('{cm:RemainingTime} ')+TimeStr1;
// LabelTime3.Caption:=ExpandConstant('{cm:AllElapsedTime}')+TimeStr3;
Result := ISDoneCancel;
end;
procedure CancelButtonOnClick(Sender: TObject);
begin
SuspendProc;
if MsgBox(SetupMessage(msgExitSetupMessage), mbConfirmation, MB_YESNO) = IDYES then
ISDoneCancel:=1;
ResumeProc;
end;
procedure HideControls;
begin
WizardForm.FileNamelabel.Hide;
ISDoneProgressBar1.Hide;
LabelPct1.Hide;
LabelCurrFileName.Hide;
LabelTime1.Hide;
LabelTime2.Hide;
MyCancelButton.Hide;
end;
procedure CreateControls;
var PBTop:integer;
begin
PBTop:=ScaleY(165); //165
ISDoneProgressBar1 := TNewProgressBar.Create(WizardForm);
with ISDoneProgressBar1 do begin
Parent := WizardForm; //:= WizardForm.InstallingPage;
Height := ScaleY(20); //WizardForm.ProgressGauge.Height;
Left := ScaleX(65);
Top := PBTop;
Width := ScaleX(470);
Max := 1000;
end;
LabelPct1 := TLabel.Create(WizardForm);
with LabelPct1 do begin
Parent := WizardForm;
AutoSize := true;
Font.Height:=-25;
Left := ISDoneProgressBar1.Left -30 + ISDoneProgressBar1.Width div 2;
Top := ISDoneProgressBar1.Top + ScaleY(80);
Width := ScaleX(80);
end;
LabelCurrFileName := TLabel.Create(WizardForm);
with LabelCurrFileName do begin
Parent := WizardForm;
AutoSize := False;
Width := ISDoneProgressBar1.Width+ScaleX(30);
Left := ScaleX(65);
Top := ScaleY(140);
Height :=ScaleY(25);
// Font.Color:= clWhite;
Font.Size:= 10;
end;
LabelTime1 := TLabel.Create(WizardForm);
with LabelTime1 do begin
Parent := WizardForm;
AutoSize := False;
Width := ISDoneProgressBar1.Width div 2;
Left := ScaleX(65);
Top := PBTop + ScaleY(30);
Height :=ScaleY(25);
Font.Size:= 8;
end;
LabelTime2 := TLabel.Create(WizardForm);
with LabelTime2 do begin
Parent := WizardForm;
AutoSize := False;
Width := ScaleX(200);
Left := Scalex (360); //Original 335 fonte 10
Top := LabelTime1.Top;
Height :=ScaleY(25);
Font.Size:= 8;
end;
// LabelTime3 := TLabel.Create(WizardForm);
// with LabelTime3 do begin
// Parent := WizardForm; //FinishedPage para aparecer na ultima pagina
// AutoSize := False;
// Font.Color:= clWhite; //Black
// Width := 250;
// Left := 10;
// Top := 330;
// Height :=ScaleY(25);
// Font.Size:= 8;
// end;
MyCancelButton:=TButton.Create(WizardForm);
with MyCancelButton do begin
Parent := WizardForm;
Top := ScaleY(360);
Left := ScaleX(410);
Width := ScaleX(90);
Height := ScaleY(25);
Caption := 'Cancelar';
Top:=WizardForm.cancelbutton.top;
OnClick:=#CancelButtonOnClick;
end;
end;
////////////////////////////////////CONTADOR/COUNTER/////////////////////////
function GetTickCount: DWORD; external 'GetTickCount#kernel32.dll stdcall';
var
StartTick: DWORD;
PercentLabel: TNewStaticText;
ElapsedLabel: TNewStaticText;
RemainingLabel: TNewStaticText;
function TicksToStr(Value: DWORD): string;
var
I: DWORD;
Hours, Minutes, Seconds: Integer;
begin
I := Value div 1000;
Seconds := I mod 60;
I := I div 60;
Minutes := I mod 60;
I := I div 60;
Hours := I mod 24;
Result := Format('%.2d:%.2d:%.2d', [Hours, Minutes, Seconds]);
end;
procedure InitializeWizard4();
begin
PercentLabel := TNewStaticText.Create(WizardForm);
PercentLabel.Parent := WizardForm;
PercentLabel.AutoSize := true;
PercentLabel.Font.Height:=-25; //SetBounds(245,220,150,20)
PercentLabel.Left := ScaleX(245); //esquerda
PercentLabel.Top := ScaleY(220); //altura de cima para baixo
PercentLabel.Width := ScaleX(150); //comprimento
PercentLabel.Height := ScaleY(20); //tamanho
ElapsedLabel := TNewStaticText.Create(WizardForm);
ElapsedLabel.Parent := WizardForm;
ElapsedLabel.AutoSize := False;
ElapsedLabel.Font.Size:= 8; //SetBounds(65,190,150,20)
ElapsedLabel.Left := ScaleX(65);
ElapsedLabel.Top := ScaleY(190);
ElapsedLabel.Width := ScaleX(150);
ElapsedLabel.Height := ScaleY(20);
RemainingLabel := TNewStaticText.Create(WizardForm);
RemainingLabel.Parent := WizardForm;
RemainingLabel.AutoSize := False;
RemainingLabel.Font.Size:= 8; // SetBounds(410,190,150,20)
RemainingLabel.Left := ScaleX(410);
RemainingLabel.Top := ScaleY(190);
RemainingLabel.Width := ScaleX(150);
RemainingLabel.Height := ScaleY(20);
end;
procedure CurPageChanged5(CurPageID: Integer);
begin
PercentLabel.Visible := CurPageID = wpInstalling;
ElapsedLabel.Visible := CurPageID = wpInstalling;
RemainingLabel.Visible := CurPageID = wpInstalling;
StartTick := GetTickCount;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
if CurPageID= wpInstalling then
begin
Cancel := False;
if ExitSetupMsgBox then
begin
Cancel := True;
Confirm := False;
PercentLabel.Visible := False;
ElapsedLabel.Visible := False;
RemainingLabel.Visible := False;
end;
end;
end;
procedure CurInstallProgressChanged(CurProgress, MaxProgress: Integer);
var
CurTick: DWORD;
begin
CurTick := GetTickCount;
PercentLabel.Caption :=
Format('%.2f %%', [(CurProgress * 100.0) / MaxProgress]);
ElapsedLabel.Caption :=
Format('Decorido: %s', [TicksToStr(CurTick - StartTick)]);
if CurProgress > 0 then
begin
RemainingLabel.Caption :=
Format('Restante: %s', [TicksToStr(
((CurTick - StartTick) / CurProgress) * (MaxProgress - CurProgress))]);
end;
end;
You gonna have to change your ISDoneInit "$F777" to "$1111"
It's something like this 👇
if ISDoneInit(ExpandConstant('{src}\records.inf'), $1111, Comps1,Comps2,Comps3, MainForm.Handle, 512, #ProgressCallback) then
begin
and you don't have to add a another time count function to get this...just remove it...
Disable two buttons on the same page
I tried several ways but did not get the closer this example was not correct
[button next = with time] [button back= no time (only disable)]
help to find the error bound
[Code]
var
Counter: Integer;
TimerID: Integer;
type
TTimerProc = procedure(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR;
SysTime: DWORD);
function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
external 'wrapcallback#files:InnoCallback.dll stdcall';
function SetTimer(hWnd: HWND; nIDEvent, uElapse: UINT;
lpTimerFunc: UINT): UINT; external 'SetTimer#user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL;
external 'KillTimer#user32.dll stdcall';
procedure OnTimerTick(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR;
SysTime: DWORD);
begin
Counter := Counter - 1;
begin
Counter := Counter - 1;
if Counter <= 0 then
begin
WizardForm.NextButton.Enabled := True;
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall);
if TimerID <> 0 then
KillTimer(0, TimerID);
end
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall) +
IntToStr(Counter);
end;
// begin
WizardForm.BackButton.Enabled := True;
if TimerID <> 0 then
begin
if KillTimer(0, TimerID) then
TimerID := 0;
end;
end;
procedure DisableNextButton(Timeout: Integer);
var
TimerCallback: LongWord;
begin
Counter := Timeout;
WizardForm.NextButton.Enabled := False;
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall) + IntToStr(Counter);
TimerCallback := WrapTimerProc(#OnTimerTick, 4);
TimerID := SetTimer(0, 0, 1000, TimerCallback);
end;
procedure DisableBackButton(Timeout: UINT);
var
TimerCallback: LongWord;
begin
WizardForm.BackButton.Enabled := False;
TimerCallback := WrapTimerProc(#OnTimerTick, 4);
TimerID := SetTimer(0, 0, Timeout, TimerCallback);
end;
procedure CurPageChanged5(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then
DisableNextButton(10);
end;
procedure CurPageChanged6(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then
DisableBackButton(5000);
end;
To disable both buttons, the next button and back button for a specified time while only next button will have the countdown timer caption, you can use the following modified script based on this post:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Files]
Source: "InnoCallback.dll"; DestDir: "{tmp}"; Flags: dontcopy
[Code]
var
Counter: Integer;
TimerID: Integer;
type
TTimerProc = procedure(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR;
SysTime: DWORD);
function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
external 'wrapcallback#files:InnoCallback.dll stdcall';
function SetTimer(hWnd: HWND; nIDEvent, uElapse: UINT;
lpTimerFunc: UINT): UINT; external 'SetTimer#user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL;
external 'KillTimer#user32.dll stdcall';
procedure OnTimerTick(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR;
SysTime: DWORD);
begin
Counter := Counter - 1;
if Counter <= 0 then
begin
WizardForm.BackButton.Enabled := True;
WizardForm.NextButton.Enabled := True;
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
if TimerID <> 0 then
KillTimer(0, TimerID);
end
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext) +
IntToStr(Counter);
end;
procedure DisableNavigateButtons(Timeout: Integer);
var
TimerCallback: LongWord;
begin
Counter := Timeout;
WizardForm.BackButton.Enabled := False;
WizardForm.NextButton.Enabled := False;
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext) +
IntToStr(Counter);
TimerCallback := WrapTimerProc(#OnTimerTick, 4);
TimerID := SetTimer(0, 0, 1000, TimerCallback);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectDir then
DisableNavigateButtons(5);
end;
Is it possible to check the position of ScrollBar in wpLicense Page in Inno Setup without having to write custom memo page?
e.g.
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpLicense then
WizardForm.LicenseAcceptedRadio.Enabled := False;
WizardForm.LicenseNotAcceptedRadio.Enabled := False;
if ScrollBar.Position := ScrollBar.Max then
WizardForm.LicenseAcceptedRadio.Enabled := True;
WizardForm.LicenseNotAcceptedRadio.Enabled := True;
end;
There is no direct access to those scroll bars, however you can use the GetScrollInfo function this way:
[code]
const
SB_VERT = 1;
SIF_RANGE = 1;
SIF_POS = 4;
SIF_PAGE = 2;
type
TScrollInfo = record
cbSize: UINT;
fMask: UINT;
nMin: Integer;
nMax: Integer;
nPage: UINT;
nPos: Integer;
nTrackPos: Integer;
end;
function GetScrollInfo(hWnd: HWND; BarFlag: Integer;
var ScrollInfo: TScrollInfo): BOOL;
external 'GetScrollInfo#user32.dll stdcall';
procedure CurPageChanged(CurPageID: Integer);
var
ScrollInfo: TScrollInfo;
begin
if CurPageID = wpLicense then
begin
ScrollInfo.cbSize := SizeOf(ScrollInfo);
ScrollInfo.fMask := SIF_RANGE or SIF_POS or SIF_PAGE;
if GetScrollInfo(WizardForm.LicenseMemo.Handle, SB_VERT, ScrollInfo) then
if ScrollInfo.nPos = ScrollInfo.nMax - ScrollInfo.nPage then
MsgBox('You are at the end of the license!', mbInformation, MB_OK);
end;
end;
That is what I have now. It works, however if you find any issues, just say as I like comments.
procedure OnScrollPosition(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR;
SysTime: DWORD);
var
ScrollInfo: TScrollInfo;
begin
ScrollInfo.cbSize := SizeOf(ScrollInfo);
ScrollInfo.fMask := SIF_RANGE or SIF_POS or SIF_PAGE;
if GetScrollInfo(WizardForm.LicenseMemo.Handle, SB_VERT, ScrollInfo) then
if ScrollInfo.nPos = ScrollInfo.nMax - ScrollInfo.nPage then
begin
WizardForm.LicenseAcceptedRadio.Enabled := True;
WizardForm.LicenseNotAcceptedRadio.Enabled := True;
end;
end;
procedure ScrollPosition();
var
TimerCallback: LongWord;
begin
TimerCallback := WrapTimerProc(#OnScrollPosition, 4);
TimerID := SetTimer(0, 0, 500, TimerCallback);
end;
procedure CurPageChanged(CurPageID: Integer);
var
ScrollInfo: TScrollInfo;
begin
if CurPageID = wpInstalling then
StartSlideTimer
else
KillSlideTimer;
if CurPageID = wpLicense then
WizardForm.LicenseAcceptedRadio.Enabled := False;
WizardForm.LicenseNotAcceptedRadio.Enabled := False;
ScrollPosition
end;