#define NeedSize 43809
#define NeedInstallSize 67890
#include "TShadowLabel.iss"
[Setup]
AppName=MyApp
AppVerName=MyApp
DefaultDirname={pf}\MyApp
DefaultGroupName=MyApp
[CustomMessages]
TotalSpace=Всего места на диске:
FreeSpace=Доступно места на диске:
InstallSpace=Требуется места для установки:
NeedSpace=Требуется места на диске:
[ code]
var
TotalSpaceLabel, FreeSpaceLabel, NeedSpacelabel, InstallSpaceLabel: TShadowLabel;
FreeMB, TotalMB: Cardinal;
function ReleaseCapture(): Longint; external '
ReleaseCapture@user32.dll stdcall';
procedure LabelOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(WizardForm.Handle,$0112,$F012,0)
end;
function NumToStr(Float: Extended): String;
begin
Result:= format('%.2n', [Float]); StringChange(Result, ',', '.');
while (Result[Length(Result)] = '0')or((Result[Length(Result)] = '.')and(Pos('.', Result) > 0)) do
SetLength(Result, Length(Result)-1);
end;
function MbOrTb(Float: Extended): String;
begin
if Float < 1024 then Result:= NumToStr(Float)+' Мб' else
if Float/1024 < 1024 then Result:= NumToStr(Float/1024)+' Гб' else
Result:= NumToStr(Float/(1024*1024))+' Тб';
end;
procedure DirEditOnChange(Sender: TObject);
var
Drive: String;
begin
Drive:= ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Drive, True, FreeMB, TotalMB);
SetShadowLabelCaption(TotalSpaceLabel, ExpandConstant('{cm:TotalSpace} ')+MbOrTb(TotalMB));
SetShadowLabelCaption(FreeSpaceLabel, ExpandConstant('{cm:FreeSpace} ')+MbOrTb(FreeMB)+' ('+IntToStr(round(FreeMB*100/TotalMB))+'% )');
WizardForm.NextButton.Enabled:= (FreeMB>{#NeedInstallSize})and(FreeMB>{#NeedSize});
if WizardForm.NextButton.Enabled then SetShadowLabelColor(FreeSpaceLabel, clsilver, clWhite) else SetShadowLabelColor(FreeSpaceLabel, clblack, $0000FF);
end;
procedure InitializeWizard();
begin
with WizardForm do begin
Bevel.Hide;
InnerNotebook.Hide;
OuterNotebook.Hide;
Position:=poScreenCenter;
Color := clGray;
end;
TotalSpaceLabel:= CreateShadowLabel(WizardForm, '', ScaleX(0),ScaleY(120), ScaleX(300), ScaleY(20), 'tahoma', 14, 1, [], clWhite, clsilver, True, False, taCenter);
FreeSpaceLabel:= CreateShadowLabel(WizardForm, '', ScaleX(0),ScaleY(140), ScaleX(300), ScaleY(20), 'tahoma', 14, 1, [], clWhite, clsilver, True, False, taCenter);
InstallSpacelabel:= CreateShadowLabel(WizardForm, ExpandConstant('{cm:InstallSpace} ')+MbOrTb({#NeedInstallSize}), ScaleX(0),ScaleY(160), ScaleX(300), ScaleY(20), 'tahoma', 14, 1, [], clWhite, clsilver, True, False, taCenter);
NeedSpaceLabel:= CreateShadowLabel(WizardForm, ExpandConstant('{cm:NeedSpace} ')+MbOrTb({#NeedSize}), ScaleX(0),ScaleY(180), ScaleX(300), ScaleY(20), 'tahoma', 14, 1, [], clWhite, clsilver, True, False, taCenter);
WizardForm.DiskSpaceLabel.Hide;
WizardForm.DirEdit.OnChange:= @DirEditOnChange;
//Создаем лейбл на всю форму, чтоб ее можно было двигать
with TLabel.Create(WizardForm) do begin
Parent:=WizardForm;
AutoSize:=False;
Top:=0;
Left:=0;
Width:=WizardForm.Width;
Height:= WizardForm.Height
Transparent:=True;
OnMouseDown:=@LabelOnMouseDown;
end;
end;
procedure HideComponents;
begin
HideShadowLabel(TotalSpaceLabel);
HideShadowLabel(FreeSpaceLabel);
HideShadowLabel(InstallSpacelabel);
HideShadowLabel(NeedSpaceLabel);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
HideComponents;
case CurPageID of
wpSelectDir:
begin
ShowShadowLabel(TotalSpaceLabel);
ShowShadowLabel(FreeSpaceLabel);
ShowShadowLabel(InstallSpacelabel);
ShowShadowLabel(NeedSpaceLabel);
DirEditOnChange(nil);
end;
end;
end;