[Code ]
#define A = (Defined UNICODE) ? "W" : "A"
function LoadIcon(hInstance: UINT; lpIconName: UINT): HICON; external 'LoadIcon{#A}@user32.dll stdcall';
const
IDI_APPLICATION = 32512; //Default application icon.
IDI_ASTERISK = 32516; //Asterisk icon. Same as IDI_INFORMATION.
IDI_ERROR = 32513; //Hand-shaped icon.
IDI_EXCLAMATION = 32515; //Exclamation point icon. Same as IDI_WARNING.
IDI_HAND = 32513; //Hand-shaped icon. Same as IDI_ERROR.
IDI_INFORMATION = 32516; //Asterisk icon.
IDI_QUESTION = 32514; //Question mark icon.
IDI_SHIELD = 32518; //Security Shield icon.
IDI_WARNING = 32515; //Exclamation point icon.
IDI_WINLOGO = 32517; //Default application icon. Windows 2000: Windows logo icon.
procedure InitializeWizard();
begin
MsgBoxEx(WizardForm.Handle, 'Test', 'Test', MB_OK, LoadIcon(0, IDI_ASTERISK), 0);
end;
[Registry]
; Запуск от имени администратора
Root: HKCU; SubKey: Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers; ValueType: string; ValueName: {app}\{#ExeName}; ValueData: RUNASADMIN; Check: CheckError; Flags: uninsdeletevalue uninsdeletekeyifempty
var
ButtonPanel: array [0..4] of TPanel;
ButtonImage: array [0..4] of TBitmapImage;
ButtonLabel: array [0..4] of TLabel;
procedure ButtonLabelClick(Sender: TObject);
var
Button: TButton;
begin
with WizardForm do
begin
case TLabel(Sender).Tag of
0: Button := BackButton;
1: Button := NextButton;
2: Button := CancelButton;
3: Button := DirBrowseButton;
4: Button := GroupBrowseButton;
else exit
end;
end;
Button.OnClick(Button);
end;
procedure ButtonLabelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ButtonImage[TLabel(Sender).Tag].Left:= -ScaleX({#ButtonWidth});
end;
procedure ButtonLabelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ButtonImage[TLabel(Sender).Tag].Left := ScaleX(0);
end;
procedure LoadButtonImage(AButton: TButton; AButtonIndex: integer);
var
Image: TBitmapImage;
Panel: TPanel;
Labl: TLabel;
begin
Panel:=TPanel.Create(WizardForm)
with Panel do
begin
SetBounds(AButton.Left,AButton.Top,AButton.Width,AButton.Height);
Tag := AButtonIndex;
Parent := AButton.Parent;
end;
ButtonPanel[AButtonIndex] := Panel;
Image:=TBitmapImage.Create(WizardForm)
with Image do
begin
Width := ScaleX({#TextureWidth});
Height := ScaleY({#TextureHeight});
Enabled := False;
Bitmap.LoadFromResourceName(HInstance, '_IS_BUTTON');
Parent := Panel;
end;
ButtonImage[AButtonIndex]:=Image;
with TLabel.Create(WizardForm) do
begin
Tag := AButtonIndex;
Parent := Panel;
Width := Panel.Width;
Height := Panel.Height;
Transparent := True;
OnClick := @ButtonLabelClick;
OnDblClick := @ButtonLabelClick;
OnMouseDown := @ButtonLabelMouseDown;
OnMouseUp := @ButtonLabelMouseUp;
end;
Labl:=TLabel.Create(WizardForm)
with Labl do
begin
Autosize := True;
Alignment := taCenter;
Tag := AButtonIndex;
Transparent := True;
Font.Color := {#ButtonFontColor};
Caption := AButton.Caption;
OnClick := @ButtonLabelClick;
OnMouseDown := @ButtonLabelMouseDown;
OnMouseUp := @ButtonLabelMouseUp;
OnDblClick := @ButtonLabelClick;
Parent := Panel;
end;
ButtonLabel[AButtonIndex]:= Labl;
end;
procedure UpdateButton(AButton: TButton;AButtonIndex: integer);
begin
ButtonPanel[AButtonIndex].Visible := AButton.Visible;
with ButtonLabel[AButtonIndex] do
begin
Caption := AButton.Caption;
Left := ButtonPanel[AButtonIndex].Width div 2 - ButtonLabel[AButtonIndex].Width div 2;
Top := ButtonPanel[AButtonIndex].Height div 2 - ButtonLabel[AButtonIndex].Height div 2;
end;
end;
procedure ButtonTextures();
begin
with WizardForm do
begin
BackButton.Left:=ScaleX(270);
BackButton.Top:=ScaleY(365);
BackButton.Width:={#ButtonWidth};
BackButton.Height:={#ButtonHeight};
NextButton.Left:=ScaleX(380);
NextButton.Top:=ScaleY(365);
NextButton.Width:={#ButtonWidth};
NextButton.Height:={#ButtonHeight};
CancelButton.Left:=ScaleX(490);
CancelButton.Top:=ScaleY(365);
CancelButton.Width:={#ButtonWidth};
CancelButton.Height:={#ButtonHeight};
DirBrowseButton.Width:={#ButtonWidth};
DirBrowseButton.Height:={#ButtonHeight};
GroupBrowseButton.Width:={#ButtonWidth};
GroupBrowseButton.Height:={#ButtonHeight};
LoadButtonImage(BackButton,0);
LoadButtonImage(NextButton,1);
LoadButtonImage(CancelButton,2);
LoadButtonImage(DirBrowseButton,3);
LoadButtonImage(GroupBrowseButton,4);
end;
end;
procedure SetStateNewButtons(CurPageID: Integer);
begin
UpdateButton(WizardForm.BackButton,0);
UpdateButton(WizardForm.NextButton,1);
UpdateButton(WizardForm.CancelButton,2);
UpdateButton(WizardForm.DirBrowseButton,3);
UpdateButton(WizardForm.GroupBrowseButton,4);
end;[/SPOILER]
Они у меня текструированы ни че не пойму...текстурируются стандартные кнопки
var
IsCustomFontInstalled: boolean;
FontName: string;
BevelF1,BevelF2: TBevel;
WelcomeLabel,DirLabel: TLabel;
function AddFontResource(FileName: PAnsiChar): Integer; external 'AddFontResourceA@gdi32.dll stdcall';
function RemoveFontResource(FileName: PAnsiChar): BOOL; external 'RemoveFontResourceA@gdi32.dll stdcall';
procedure LoadSkin(lpszPath: String; lpszIniFileName: String);
external 'LoadSkin@files:isskin.dll stdcall';
procedure UnloadSkin();
external 'UnloadSkin@files:isskin.dll stdcall';
function InitializeSetup(): Boolean;
begin
ExtractTemporaryFile('{#Font}');
IsCustomFontInstalled:=AddFontResource(ExpandConstant('{tmp}')+'\{#Font}')>0;
if IsCustomFontInstalled then SendMessage(HWND_BROADCAST,$1D,0,0);
if FontExists('{#FontName}') then FontName:='{#FontName}' else FontName:='Arial';
ExtractTemporaryFile('Skin.cjstyles');
LoadSkin(ExpandConstant('{tmp}\Skin.cjstyles'), '');
Result:= true
end;
// НАЧАЛО РАЗМЕТКА ФОРМЫ ;
procedure InitializeWizard();
begin
#ifdef NeedSize
SizeInt:= {#NeedSize}
#else
SizeInt:= GetSize;
#endif
ExtractTemporaryFile('Fon.bmp');
with WizardForm do begin
ClientWidth:=ScaleX(600); // ШИРИНА
ClientHeight:=ScaleY(400); // ВЫСОТА
Center; // ВЫРАВНИВАЕМ ИНСТАЛЛ ПО ЦЕНТРУ
InnerNotebook.Hide;
OuterNotebook.Hide;
Bevel.Hide; // СКРЫВАЕМ СТАНДАРТНЫЕ БЕВЕЛЫ
// КОНЕЦ РАЗМЕТКА ФОРМЫ ;
// НАЧАЛО ДВИГАЕМ КНОПКИ
with WizardForm.NextButton do
begin
Left := ScaleX(380);
Top := ScaleY(365);
end;
with WizardForm.CancelButton do
begin
Left := ScaleX(490);
Top := ScaleY(365);
end;
with WizardForm.BackButton do
begin
Left := ScaleX(270);
Top := ScaleY(365);
end;
with WizardForm.DirBrowseButton do
begin
Left := ScaleX(465);
Top := ScaleY(200);
Parent:= WizardForm;
end;
with WizardForm.GroupBrowseButton do
begin
Left := ScaleX(465);
Top := ScaleY(200);
Parent:= WizardForm;
end;
// КОНЕЦ ДВИГАЕМ КНОПКИ
// НАЧАЛО СОЗДАНИЕ БЕВЕЛОВ
BevelF1:= TBevel.Create(WizardForm);
with BevelF1 do
begin
Left := ScaleX(0);
Top := ScaleY(50);
Width := ScaleX(600);
Height := ScaleY(2);
Parent:=WizardForm;
end;
BevelF2:= TBevel.Create(WizardForm);
with BevelF2 do
begin
Left := ScaleX(0);
Top := ScaleY(350);
Width := ScaleX(600);
Height := ScaleY(2);
Parent:=WizardForm;
end;
// КОНЕЦ СОЗДАНИЕ БЕВЕЛОВ
// НАЧАЛО СОЗДАНИЕ ЛЕЙБЛОВ
WelcomeLabel:= TLabel.Create(WizardForm);
with WelcomeLabel do begin
AutoSize:=False;
SetBounds(ScaleX(25), ScaleY(219), ScaleX(550), ScaleY(80));
WordWrap:=True;
Alignment := taCenter;
Transparent:=True;
Font.Name:= FontName;
Font.Size:= 12;
Font.Color:=$FFFFFF;
Caption:= ExpandConstant('{cm:Welcome}');
Parent:=WizardForm;
end;
DirLabel:= TLabel.Create(WizardForm);
with DirLabel do begin
AutoSize:=False;
SetBounds(ScaleX(25), ScaleY(130), ScaleX(550), ScaleY(80));
WordWrap:=True;
//Alignment := taCenter;
Transparent:=True;
Font.Name:= FontName;
Font.Size:= 12;
Font.Color:=$FFFFFF;
Caption:= ExpandConstant('{cm:SelectDir}');
Parent:=WizardForm;
end;
with WizardForm.DirEdit do
begin
Parent:=WizardForm;
Left := ScaleX(25);
Top := ScaleY(200);
Width := ScaleX(430);
Height := ScaleY(23);
Font.Color:=$FFFFFF;
Font.Size:= 10;
Font.Name:=FontName;
end;
with WizardForm.GroupEdit do
begin
Parent:=WizardForm;
Left := ScaleX(25);
Top := ScaleY(200);
Width := ScaleX(430);
Height := ScaleY(23);
Font.Color:=$FFFFFF;
Font.Size:= 10;
Font.Name:=FontName;
end;
// КОНЕЦ СОЗДАНИЕ ЛЕЙБЛОВ
ButtonTextures(); // КНОПКИ
NeedSpaceLabel := TLabel.Create(WizardForm);
NeedSpaceLabel.SetBounds(ScaleX(25), ScaleY(295), ScaleX(209), ScaleY(13));
NeedSpaceLabel.Font.Name:= FontName;
NeedSpaceLabel.Font.Size:= 12;
NeedSpaceLabel.Font.Color:=$FFFFFF;
NeedSpaceLabel.Parent := WizardForm;
NeedSpaceLabel.Transparent:=true;
FreeSpaceLabel := TLabel.Create(WizardForm);
FreeSpaceLabel.SetBounds(ScaleX(25), ScaleY(320), ScaleX(209), ScaleY(13));
FreeSpaceLabel.Font.Name:= FontName;
FreeSpaceLabel.Font.Size:= 12;
FreeSpaceLabel.Font.Color:=$FFFFFF;
FreeSpaceLabel.Parent := WizardForm;
FreeSpaceLabel.Transparent:=true;
WizardForm.DirEdit.OnChange:= @GetFreeSpaceCaption;
WizardForm.DirEdit.Text:= WizardForm.DirEdit.Text + #0;
// НАЧАЛО ПОДМЕНА ШРИФТОВ
WelcomeLabel.Font.Handle := IsPicReFont(WelcomeLabel.Font.Handle, WelcomeLabel.Font.Height, FW_MEDIUM, False);
DirLabel.Font.Handle := IsPicReFont(DirLabel.Font.Handle, DirLabel.Font.Height, FW_MEDIUM, False);
DirEdit.Font.Handle := IsPicReFont(DirEdit.Font.Handle, DirEdit.Font.Height, FW_THIN, False);
GroupEdit.Font.Handle := IsPicReFont(GroupEdit.Font.Handle, GroupEdit.Font.Height, FW_THIN, False);
NeedSpaceLabel.Font.Handle := IsPicReFont(NeedSpaceLabel.Font.Handle, NeedSpaceLabel.Font.Height, FW_MEDIUM, False);
FreeSpaceLabel.Font.Handle := IsPicReFont(FreeSpaceLabel.Font.Handle, FreeSpaceLabel.Font.Height, FW_MEDIUM, False);
// КОНЕЦ ПОДМЕНА ШРИФТОВ
// ЦВЕТ ПРОЗРАЧНОСТИ - $000008. (УКАЗЫВАЕМ ЕГО ДЛЯ ЭЛЕМЕНТОВ,КОТОРЫЕ ДОЛЖНЫ БЫТЬ ПРОЗРАЧНЫМИ)
Color := $000008;
DirEdit.Color := $000008;
GroupEdit.Color := $000008;
// ЗАПУСКАЕМ
IsPicInit(Handle);
// ДОБАВЛЯЕМ ИЗОБРАЖЕНИЕ НА ЗАДНИЙ ФОН
IsPicAddImg(ExpandConstant('{tmp}\Fon.bmp'));
end;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:=False; // ЗАКРЫТИЕ ИНСТАЛЛА
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
if (PageID =wpReady)then // ПРОПУСК СТРАНИЦЫ ГОТОВНОСТИ
Result:= True;
end;
procedure ShowComponents(CurPageID: Integer);
begin
case CurPageID of
wpWelcome: // СТРАНИЦА ПРИВЕТСТВИЯ
begin
WelcomeLabel.Show;
end;
wpSelectDir: // СТРАНИЦА ВЫБОРА ПАПКИ НАЗНАЧЕНИЯ
begin
GetFreeSpaceCaption(nil)
DirLabel.Show;
WizardForm.DirEdit.Show;
WizardForm.DirBrowseButton.Show;
NeedSpaceLabel.Show;
FreeSpaceLabel.Show;
end;
wpSelectProgramGroup: // СТРАНИЦА ВЫБОРА ПРОГРАММНОЙ ГРУППЫ
begin
WizardForm.GroupEdit.Show;
WizardForm.GroupBrowseButton.Show;
WizardForm.NextButton.Caption:= 'Установить';
end;
wpInstalling: // СТРАНИЦА УСТАНОВКИ
begin
end;
wpFinished: // СТРАНИЦА ЗАВЕРШЕНИЯ УСТАНОВКИ
begin
end;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
UnpackingISDone(CurStep); // IsDone РАСПАКОВКА АРХИВОВ ;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
WizardForm.CancelButton.Caption:= 'Выход';
WizardForm.Caption:= ExpandConstant('{cm:SetupWindowTitle}');
WelcomeLabel.Hide;
DirLabel.Hide;
WizardForm.GroupEdit.Hide;
WizardForm.DirBrowseButton.Hide;
WizardForm.GroupBrowseButton.Hide;
WizardForm.DirEdit.Hide;
NeedSpaceLabel.Hide;
FreeSpaceLabel.Hide;
ShowComponents(CurPageID); // КОМПОНЕНТЫ СТРАНИЦ
SetStateNewButtons(CurPageID); // ОБНОВЛЯЕМ ТЕКСТУРЫ КНОПОК
UnpackingISDoneFinished(CurPageID); // IsDone ЗАВЕРШЕНИЕ РАСПАКОВКИ ;
end;
procedure DeinitializeSetup();
begin
WizardForm.Free;
if IsCustomFontInstalled then
if RemoveFontResource(PAnsiChar(ExpandConstant('{tmp} ')+'\{#Font}')) then SendMessage(HWND_BROADCAST,$1D,0,0);
UnloadSkin();
// IsPicture2 ЗАВЕРШАЕМ РАБОТУ
IsPicDeInit;
end;[/SPOILER]
//******************************************* [ начало Место для установки ] ***************************************************//
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;
var
FreeMB, TotalMB: Cardinal;
NeedSize, TotalNeedSize:Integer; TotalNeedSpaceLabel,NeedSpaceLabel,FreeSpaceLabel: TLabel;
Function MbOrTb(Byte: Extended): String;
begin
if Byte < 1024 then Result:= NumToStr(Byte) + ' Мб' else
if Byte/1024 < 1024 then Result:= NumToStr(round(Byte/1024*100)/100) + ' Гб' else
Result:= NumToStr(round((Byte/(1024*1024))*100)/100) + ' Тб';
end;
procedure GetFreeSpaceCaption(Sender: TObject);
var
Path: String;
begin
Path := ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
NeedSpaceLabel.Caption := 'Игра займет на диске: '+ MbOrTb(NeedSize);
TotalNeedSpaceLabel.Caption := 'Для распаковки требуется: '+ MbOrTb(TotalNeedSize);
FreeSpaceLabel.Caption := 'Доступно места на диске: '+ MbOrTb(FreeMB);
WizardForm.NextButton.Enabled:= (FreeMB>TotalNeedSize);
WizardForm.NextButton.Enabled:= (FreeMB>NeedSize);
if (FreeMB<TotalNeedSize) then
FreeSpaceLabel.Font.Color:=clRed else
FreeSpaceLabel.Font.Color:=WizardForm.Font.Color;
//if (FreeMB<NeedSize) then
// FreeSpaceLabel.Font.Color:=clRed else
// FreeSpaceLabel.Font.Color:=WizardForm.Font.Color;
end;
procedure InitializeWizard();
begin
NeedSize := {#NeedSize};
TotalNeedSize := {#TotalNeedSize};
WizardForm.DiskSpaceLabel.Hide;
TotalNeedSpaceLabel := TLabel.Create(WizardForm);
TotalNeedSpaceLabel.Parent := WizardForm.SelectDirPage;
TotalNeedSpaceLabel.SetBounds(ScaleX(5), ScaleY(200), ScaleX(209), ScaleY(13));
FreeSpaceLabel := TLabel.Create(WizardForm);
FreeSpaceLabel.Parent := WizardForm.SelectDirPage;
FreeSpaceLabel.SetBounds(ScaleX(5), ScaleY(180), ScaleX(209), ScaleY(13));
NeedSpaceLabel := TLabel.Create(WizardForm);
NeedSpaceLabel.Parent := WizardForm.SelectDirPage;
NeedSpaceLabel.SetBounds(ScaleX(5), ScaleY(220), ScaleX(209), ScaleY(13));
WizardForm.DirEdit.OnChange := @GetFreeSpaceCaption;
end;
//******************************************* [ конец Место для установки ] ***************************************************//
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectDir then GetFreeSpaceCaption(nil);
end;
[/MORE]
#define ButtonWidth "90" ; øèðèíà êíîïêè
#define ButtonHeight "23" ; âûñîòà
#define ButtonFontColor "$FFFFFF" ;öâåò øðèôòà êíîïîê
#define TextureWidth "180" ;øèðèíà êàðòèíêè-òåêñòóðû
#define TextureHeight "23" ;âûñîòà
[code ]
var
ButtonPanel: array [0..4] of TPanel;
ButtonImage: array [0..4] of TBitmapImage;
ButtonLabel1: array [0..4] of TLabel;
ButtonLabel2: array [0..4] of TLabel;
procedure ButtonLabelClick(Sender: TObject);
var
Button: TButton;
begin
with WizardForm do
begin
case TLabel(Sender).Tag of
[B] 0: Button := BackButton;
1: Button := NextButton;
2: Button := CancelButton;
3: Button := DirBrowseButton;
4: Button := GroupBrowseButton;[/B]
else exit
end;
end;
Button.OnClick(Button);
end;
procedure ButtonLabelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ButtonImage[TLabel(Sender).Tag].Left:= -ScaleX({#ButtonWidth});
end;
procedure ButtonLabelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ButtonImage[TLabel(Sender).Tag].Left := ScaleX(0);
end;
procedure LoadButtonImage(AButton: TButton; AButtonIndex: integer);
var
Image: TBitmapImage;
Panel: TPanel;
Labl1: TLabel;
Labl2: TLabel;
begin
Panel:=TPanel.Create(WizardForm)
with Panel do
begin
SetBounds(AButton.Left,AButton.Top,AButton.Width,AButton.Height);
Tag := AButtonIndex;
Parent := AButton.Parent;
end;
ButtonPanel[AButtonIndex] := Panel;
Image:=TBitmapImage.Create(WizardForm)
with Image do
begin
Width := ScaleX({#TextureWidth});
Height := ScaleY({#TextureHeight});
Enabled := False;
Bitmap.LoadFromResourceName(HInstance, '_IS_BUTTON');
Parent := Panel;
end;
ButtonImage[AButtonIndex]:=Image;
[B] Labl1:=TLabel.Create(WizardForm)
with Labl1 do
begin
Tag := AButtonIndex;
Parent := Panel;
Width := Panel.Width;
Height := Panel.Height;
Transparent := True;
OnClick := @ButtonLabelClick;
OnDblClick := @ButtonLabelClick;
OnMouseDown := @ButtonLabelMouseDown;
OnMouseUp := @ButtonLabelMouseUp;
end;
Labl2:=TLabel.Create(WizardForm)
with Labl2 do
begin
Autosize := True;
Alignment := taCenter;
Tag := AButtonIndex;
Transparent := True;
Font.Color := {#ButtonFontColor};
Caption := AButton.Caption;
OnClick := @ButtonLabelClick;
OnMouseDown := @ButtonLabelMouseDown;
OnMouseUp := @ButtonLabelMouseUp;
OnDblClick := @ButtonLabelClick;
Parent := Panel;
end;[/B]
[B] ButtonLabel1[AButtonIndex]:= Labl1;
ButtonLabel2[AButtonIndex]:= Labl2;[/B]
end;
procedure UpdateButton(AButton: TButton;AButtonIndex: integer);
begin
ButtonPanel[AButtonIndex].Visible := AButton.Visible;
with ButtonLabel2[AButtonIndex] do
begin
Caption := AButton.Caption;
Left := ButtonPanel[AButtonIndex].Width div 2 - ButtonLabel2[AButtonIndex].Width div 2;
Top := ButtonPanel[AButtonIndex].Height div 2 - ButtonLabel2[AButtonIndex].Height div 2;
end;
end;
procedure ButtonTextures();
begin
with WizardForm do
begin
BackButton.Width:={#ButtonWidth};
BackButton.Height:={#ButtonHeight};
NextButton.Width:={#ButtonWidth};
NextButton.Height:={#ButtonHeight};
CancelButton.Width:={#ButtonWidth};
CancelButton.Height:={#ButtonHeight};
DirBrowseButton.Width:={#ButtonWidth};
DirBrowseButton.Height:={#ButtonHeight};
GroupBrowseButton.Width:={#ButtonWidth};
GroupBrowseButton.Height:={#ButtonHeight};
LoadButtonImage(BackButton,0);
LoadButtonImage(NextButton,1);
LoadButtonImage(CancelButton,2);
LoadButtonImage(DirBrowseButton,3);
LoadButtonImage(GroupBrowseButton,4);
end;
end;
procedure SetStateNewButtons(CurPageID: Integer);
begin
UpdateButton(WizardForm.BackButton,0);
UpdateButton(WizardForm.NextButton,1);
[B] ButtonLabel1[1].Enabled:=true;
ButtonLabel2[1].Enabled:=true;[/B]
UpdateButton(WizardForm.CancelButton,2);
UpdateButton(WizardForm.DirBrowseButton,3);
UpdateButton(WizardForm.GroupBrowseButton,4);
end;
[Code ]
var
NeedSpaceLabel,FreeSpaceLabel: TLabel;
FreeMB, TotalMB: Cardinal;
SizeStr: String;
SizeInt: Integer;
SymbolNumber: Integer;
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 GetSize(): Integer;
begin
SizeStr:= WizardForm.DiskSpaceLabel.Caption;
for SymbolNumber:= 97 to 122 do begin
while (Pos(Chr(SymbolNumber), SizeStr) > 0) do Delete(SizeStr, Pos(Chr(SymbolNumber), SizeStr),1); //Íàõîäèì âñå ñèìâîëû íèæíåãî ðåãèñòðà è óäàëÿåì
while (Pos(AnsiUppercase(Chr(SymbolNumber)), SizeStr) > 0) do Delete(SizeStr, Pos(AnsiUppercase(Chr(SymbolNumber)), SizeStr),1); end; //Íàõîäèì âñå ñèìâîëû âåðõíåãî ðåãèñòðà è óäàëÿåì
for SymbolNumber:= 192 to 255 do begin
while (Pos(Chr(SymbolNumber), SizeStr) > 0) do Delete(SizeStr, Pos(Chr(SymbolNumber), SizeStr),1); end; //Íàõîäèì âñå ñèìâîëû íèæíåãî ðåãèñòðà è óäàëÿåì
while (Pos('.', SizeStr) > 0) do Delete(SizeStr, Pos('.', SizeStr), 1) //Óäàëÿåì òî÷êè
Delete(SizeStr, Pos(',', SizeStr), 5) //Óäàëÿåì äðîáíóþ ÷àñòü
Result:= StrToInt(Trim(SizeStr)); //Ïåðåâîäèì â ÷èñëî
end;
function CompareNum(FirstNum, SecondNum: Integer): Boolean;
begin
if FirstNum < SecondNum then Result:= False else Result:= True;
end;
Function MbOrTb(Byte: Extended): String;
begin
if Byte < 1024 then Result:= NumToStr(Byte) + ' Ìá' else
if Byte/1024 < 1024 then Result:= NumToStr(round(Byte/1024*100)/100) + ' Ãá' else
Result:= NumToStr(round((Byte/(1024*1024))*100)/100) + ' Òá'
end;
procedure GetFreeSpaceCaption(Sender: TObject);
var Path: String;
begin
Path := ExtractFileDrive(WizardForm.DirEdit.Text);
GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
FreeSpaceLabel.Caption:= ExpandConstant('{cm:FreeSpace} ') + MbOrTb(FreeMB)
NeedSpaceLabel.Caption := ExpandConstant('{cm:NeedSpace} ') + MbOrTb(SizeInt)
if WizardForm.CurPageID = wpSelectDir then begin
WizardForm.NextButton.Enabled:= CompareNum(FreeMB, SizeInt)
if WizardForm.NextButton.Enabled then
begin
FreeSpaceLabel.Font.Color:=$000000;
[B] ButtonLabel1[1].Enabled:=true;
ButtonLabel2[1].Enabled:=true;[/B]
end else begin
FreeSpaceLabel.Font.Color:=$0000FF;
[B] ButtonLabel1[1].Enabled:=False;
ButtonLabel2[1].Enabled:=False;[/B]
end;
end;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
WizardForm.DirBrowseButton.Hide;
WizardForm.DirEdit.Hide;
NeedSpaceLabel.Hide;
FreeSpaceLabel.Hide;
[B]SetStateNewButtons(CurPageID);
ShowComponents(CurPageID); [/B]
end;