Kaktus
Новичок
Помогите, пожалуйста
При нажатии на любую кнопку на новой форме отмены установки выпадает ошибка
Код:
[Setup]
AppName=button texture
AppVerName=1.0
DefaultDirName={pf}\button
BitmapResource=Cls:compiler:Examples\Btn3.bmp
[_Code]
var
ButtonPanel: array of TPanel;
ButtonImage: array of TBitmapImage;
ButtonLabel: array of TLabel;
UsedButtons: array of TButton;
AButton, NoButton, YesButton: TButton;
ButtonsCount, n, i:integer;
MyExit: TSetupForm;
ReturnButtonCancelFormLbl: TLabel;
procedure ButtonLabelClick(Sender: TObject);
begin
i:= TLabel(Sender).Tag; ButtonImage[i].Left:= 0;
for n:=0 to (ButtonsCount-1) do begin
if i = n then AButton:= UsedButtons[n];
end;
AButton.OnClick(AButton);
end;
procedure ButtonLabelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
for n:=0 to (ButtonsCount-1) do begin
if i = n then AButton:= UsedButtons[n];
end;
if ButtonLabel[TLabel(Sender).Tag].Enabled then ButtonImage[TLabel(Sender).Tag].Left:=-ScaleX(AButton.Width*2);
end;
procedure ButtonLabelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if ButtonLabel[TLabel(Sender).Tag].Enabled then ButtonImage[TLabel(Sender).Tag].Left:= 0;
end;
procedure ButtonLabelMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
I:=TLabel(Sender).Tag;
for n:=0 to (ButtonsCount-1) do begin
if i = n then AButton:= UsedButtons[n];
end;
for n:=0 to (ButtonsCount-1) do begin if (ButtonLabel[n].Enabled)and(ButtonImage[n].Left <> -ScaleX(AButton.Width*2))and(I<>N) then ButtonImage[n].Left:= 0; end;
if (ButtonLabel[I].Enabled)and(ButtonImage[I].Left <> -ScaleX(AButton.Width*2)) then begin ButtonImage[I].Left:= -ScaleX(AButton.Width); end;
end;
procedure WizardLabelMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
for n:=0 to (ButtonsCount-1) do begin
if i = n then AButton:= UsedButtons[n];
end;
for n:=0 to (ButtonsCount-1) do if (ButtonLabel[n].Enabled)and(ButtonImage[n].Left <> -ScaleX(AButton.Width*2)) then begin ButtonImage[n].Left:= 0; end;
end;
procedure LoadButtonImage(Img:String; AButton: TButton);
begin
n:=ButtonsCount; SetArrayLength(ButtonPanel, n+1);
SetArrayLength(ButtonImage, n+1); SetArrayLength(ButtonLabel, n+1);
SetArrayLength(UsedButtons, n+1); UsedButtons[n]:= AButton;
ButtonPanel[n]:=TPanel.Create(WizardForm);
with ButtonPanel[n] do
begin
SetBounds(AButton.Left, AButton.Top, AButton.Width, AButton.Height);
Tag:= n;
Enabled:= AButton.Enabled;
Cursor:= AButton.Cursor;
Parent:=AButton.Parent;
BevelOuter := bvNone;
end;
ButtonImage[n]:=TBitmapImage.Create(WizardForm);
with ButtonImage[n] do
begin
SetBounds(0, 0, AButton.Width*4, AButton.Height);
Enabled:=False;
Bitmap.LoadFromResourceName(HInstance, Img);
Parent:=ButtonPanel[n];
BackColor := clNone;
SendToBack;
end;
with TLabel.Create(WizardForm) do
begin
Tag:=n;
Parent:=ButtonPanel[n];
Width:=AButton.Width;
Height:=AButton.Height;
Transparent:=True;
OnClick:=@ButtonLabelClick;
OnDblClick:=@ButtonLabelClick;
OnMouseMove:=@ButtonLabelMove;
OnMouseDown:=@ButtonLabelMouseDown;
OnMouseUp:=@ButtonLabelMouseUp;
end;
ButtonLabel[n]:=TLabel.Create(WizardForm);
with ButtonLabel[n] do
begin
Autosize:=True;
Alignment:=taCenter;
Tag:=n;
Enabled:= AButton.Enabled;
Transparent:=True;
Font.Color:=AButton.Font.Color;
Font.Size:= AButton.Font.Size;
Font.Style:= AButton.Font.Style;
Caption:=AButton.Caption;
OnClick:=@ButtonLabelClick;
OnDblClick:=@ButtonLabelClick;
OnMouseMove:=@ButtonLabelMove;
OnMouseDown:=@ButtonLabelMouseDown;
OnMouseUp:=@ButtonLabelMouseUp;
Parent:=ButtonPanel[n];
end;
ButtonsCount:= ButtonsCount+1;
end;
procedure UpdateButtons();
begin
for n:=0 to ButtonsCount-1 do begin
ButtonLabel[n].Caption:=UsedButtons[n].Caption;
ButtonPanel[n].Visible:=UsedButtons[n].Visible;
ButtonPanel[n].Left:=UsedButtons[n].Left;
ButtonPanel[n].Top:=UsedButtons[n].Top;
ButtonPanel[n].Width:=UsedButtons[n].Width;
ButtonPanel[n].Height:=UsedButtons[n].Height;
if (UsedButtons[n].Enabled = False) then ButtonImage[n].Left:= -UsedButtons[n].Width*3 else ButtonImage[n].Left:= 0;
ButtonLabel[n].Enabled:= UsedButtons[n].Enabled;
ButtonPanel[n].Enabled:= UsedButtons[n].Enabled;
ButtonLabel[n].Left:= ButtonPanel[n].Width div 2 - ButtonLabel[n].Width div 2;
ButtonLabel[n].Top:= ButtonPanel[n].Height div 2 - ButtonLabel[n].Height div 2;
end;
end;
procedure MyExitMessage();
begin
MyExit := CreateCustomForm();
with MyExit do begin
BorderIcons := [];
Position := poScreenCenter;
ClientWidth := ScaleX(230);
ClientHeight := ScaleY(100);
Caption := ExpandConstant(SetupMessage(msgExitSetupTitle));
Color := $48c1ca;
ReturnButtonCancelFormLbl:= TLabel.Create(MyExit);
with ReturnButtonCancelFormLbl do begin
Parent:= MyExit;
SetBounds(ScaleX(0), ScaleY(23), ScaleX(479), ScaleY(313));
AutoSize:= False;
OnMouseMove:= @WizardLabelMove;
end;
NoButton := TButton.Create(MyExit);
with NoButton do begin
Parent := MyExit;
Left := ScaleX(50);
Caption := 'Нет';
Top := ScaleY(60);
Width := ScaleX(60);
Height := ScaleY(25);
ModalResult:= mrNo;
end;
LoadButtonImage('_IS_Cls', NoButton);
YesButton := TButton.Create(MyExit);
with YesButton do begin
Caption := 'Да';
Parent := MyExit;
Left := ScaleX(120);
Top := ScaleY(60);
Width := ScaleX(60);
Height := ScaleY(25);
ModalResult := mrYes;
end;
LoadButtonImage('_IS_Cls', YesButton);
end;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:= False;
MyExitMessage();
if MyExit.ShowModal() = mrNo then
Cancel := False;
end;