Автор: zxcvvcxz1
Дата сообщения: 04.08.2010 12:59
Здравствуйте. У меня такой вопрос по текстурированию кнопок нарыл несколько остоновился на одном :Скрипт текстурирования кнопок, с четырмя видами состояния кнопок
Используется текстура размером 320х23, где размер одной кнопки 80х23
Текстуру сделал под кнопки при комплияции ошибка Прошу не пинать - в этом новичёк Пожалуста подправте :
[more];Скрипт текстурирования кнопок, с четырмя видами состояния кнопок
;Используется текстура размером 320х23, где размер одной кнопки 80х23
[Setup]
AppName=Test
AppVerName=Test
DefaultDirName={pf}\Test
[Name]
Name: "rus"; Name: "compiler:Name\Russian.isl";
[Files]
Source: button2.bmp; DestDir: {tmp}; Flags: dontcopy
[Code]
const
ButtonWidth = 80;
ButtonHeight = 23;
var
WizardLabel: TLabel;
ButtonPanel: array of TPanel;
ButtonImage: array of TBitmapImage;
ButtonLabel: array of TLabel;
Used Buttons: array of TB utton; // Здесь ошибка
B uttonsCount: Integer;
procedure ButtonLabelClick(Sender: TObject );
var Button: TButton; n, i: Integer;
begin
i:= TLabel( Sender).Tag; ButtonImage[i].Left:= 0
for n:=0 to ( ButtonsCount-1) do begin
if i = n then Button:= UsedButtons[n];
end;
Button.OnClick(Button)
end;
procedure ButtonLabelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if ButtonLabel[TLabel(Sender).Tag].Enabled then ButtonImage[TLabel(Sender).Tag].Left:=-ButtonWidth*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);
var n, I: Integer;
begin
I:=TLabel(Sender). Tag;
for n:=0 to (B uttonsCount-1) do begin if ( ButtonLabel[n].Enabled)and(ButtonImage[n].Left <> -ButtonWidth*2)and(I<>N) then ButtonImage[n].Left:= 0; end;
if ( ButtonLabel[I].Enabled)and(ButtonImage[I].Left <> - ButtonWidth*2) then begin ButtonImage[I].Left:= -ButtonWidth; end;
end;
procedure WizardLabelMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var n: Integer;
begin
for n:=0 to (B uttonsCount-1) do if ( ButtonLabel[n].Enabled)and(ButtonImage[n].Left <> -ButtonWidth*2) then begin B uttonImage[n].Left:= 0; end;
end;
procedure LoadButtonImage(AButton: TButton);
var n: Integer;
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)
ButtonPanel[n].SetBounds(AButton.Left, AButton.Top, AButton.Width, AButton.Height)
ButtonPanel[n].Tag:= n
ButtonPanel[n].Enabled:= AButton.Enabled
ButtonPanel[n].Parent:=AButton.Parent
ButtonImage[n]:=TBitmapImage.Create(WizardForm)
ButtonImage[n].SetBounds(ScaleX(0), ScaleY(0), ScaleX(320), ScaleY(23))
ButtonImage[n].Enabled:=False
ButtonImage[n].Bitmap.LoadFromFile(ExpandConstant('{tmp}\Button2.bmp'))
ButtonImage[n].Parent:=ButtonPanel[n]
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)
ButtonLabel[n].Autosize:=True
ButtonLabel[n].Alignment:=taCenter
ButtonLabel[n].Tag:=n
ButtonLabel[n].Enabled:= AButton.Enabled
ButtonLabel[n].Transparent:=True
ButtonLabel[n].Font.Color:=clWhite
ButtonLabel[n].Caption:=AButton.Caption
ButtonLabel[n].OnClick:=@ButtonLabelClick
ButtonLabel[n].OnDblClick:=@ButtonLabelClick
ButtonLabel[n].OnMouseMove:=@ButtonLabelMove
ButtonLabel[n].OnMouseDown:=@ButtonLabelMouseDown
ButtonLabel[n].OnMouseUp:=@ButtonLabelMouseUp
ButtonLabel[n].Parent:=ButtonPanel[n]
ButtonsCount:= ButtonsCount+1
end;
procedure UpdateB uttons();
var n: Integer;
begin
for n:=0 to Bu ttonsCount-1 do begin
ButtonLabel[n].Caption:=UsedButtons[n].Caption
ButtonPanel[n].Visible:=UsedButtons[n].Visible
if (UsedB uttons[n].Enabled = False) then But tonImage[n].Left:= -Bu ttonWidth*3 else B uttonImage[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 LicenceAcceptedRadioOnClick (Sender: TObject );
begin
WizardForm.NextButton.Enabled:= True;
UpdateButtons();
end;
procedure LicenceNotAcceptedRadioOnClick( Sender: TObject );
begin
WizardForm.NextButton.Enabled:= False;
UpdateButtons()
end;
procedure InitializeWizard();
begin
WizardLabel:= TLabel.Create(WizardForm)
WizardLabel.SetBounds(ScaleX(0), ScaleY(0), ScaleX(WizardForm.Width), ScaleY(WizardForm.Height))
WizardLabel.Transparent:= True;
WizardLabel.AutoSize:=false;
WizardLabel.OnMouseMove:=@WizardLabelMove
WizardLabel.Parent:= WizardForm;
WizardForm.BackButton.Width:= ButtonWidth
WizardForm.BackButton.Height:= ButtonHeight
WizardForm.NextButton.Width:= ButtonWidth
WizardForm.NextButton.Height:= ButtonHeight
WizardForm.CancelButton.Width:=ButtonWidth
WizardForm.CancelButton.Height:= ButtonHeight
WizardForm.DirBrowseButton.Left:=ScaleX(337)
WizardForm.DirBrowseButton.Width:= ButtonWidth
WizardForm.DirBrowseButton.Height:=ButtonHeight
WizardForm.GroupBrowseButton.Left:=ScaleX(337)
WizardForm.GroupBrowseButton.Width:= ButtonWidth
WizardForm.GroupBrowseButton.Height:=ButtonHeight
WizardForm.LicenseAcceptedRadio.OnClick:=@LicenceAcceptedRadioOnClick
WizardForm.LicenseNotAcceptedRadio.OnClick:=@LicenceNotAcceptedRadioOnClick
ExtractTemporaryFile('button2.bmp')
LoadButtonImage(WizardForm.BackButton)
LoadButtonImage(WizardForm.NextButton)
LoadButtonImage(WizardForm.CancelButton)
LoadButtonImage(WizardForm.DirBrowseButton)
LoadButtonImage(WizardForm.GroupBrowseButton)
end;
procedure CurPageChanged(CurPageID: Integer);
begin
UpdateButtons()
end;
[/more]
Скрипт+Текстура [more]http://rghost.ru/2266003[/more]