Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Аватара для GrizzlyMK

Новый участник


Сообщения: 28
Благодарности: 3

Профиль | Отправить PM | Цитировать


Изображения
Тип файла: bmp Button.bmp
(10.8 Kb, 541 просмотров)

grinda,
Вот наложение изоброжение на кнопки.
А также саме кнопки вложил.
Код: Выделить весь код
[Files]
Source: button.bmp; DestDir: {tmp}; Flags: dontcopy

*Code]
const
  ButtonWidth = 80;    //Указываем размер кнопок
  ButtonHeight = 23;

  bidBack = 0;
  bidNext = 1;
  bidCancel = 2;
  bidDirBrowse = 3;
  bidGroupBrowse = 4;

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
  ButtonImage[TLabel(Sender).Tag].Left:=0
  case TLabel(Sender).Tag of
    bidBack: Button:=WizardForm.BackButton
    bidNext: Button:=WizardForm.NextButton
    bidCancel: Button:=WizardForm.CancelButton
    bidDirBrowse: Button:=WizardForm.DirBrowseButton
    bidGroupBrowse: Button:=WizardForm.GroupBrowseButton
  else
    Exit
  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
end;

procedure ButtonLabelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ButtonImage[TLabel(Sender).Tag].Left:=0
end;

procedure LoadButtonImage(AButton: TButton; AButtonIndex: integer);
var
  Image: TBitmapImage;
  Panel: TPanel;
  Labl: TLabel;

begin
  Panel:=TPanel.Create(WizardForm)
  Panel.Left:=AButton.Left
  Panel.Top:=AButton.Top
  Panel.Width:=AButton.Width
  Panel.Height:=AButton.Height
  Panel.Tag:=AButtonIndex
  Panel.Parent:=AButton.Parent
  ButtonPanel[AButtonIndex]:=Panel

  Image:=TBitmapImage.Create(WizardForm)    //Рисунок который ложится на кнопку
  Image.Width:=160                          //Обязательно прописать оригинальный размер рисунка
  Image.Height:=23
  Image.Enabled:=False
  Image.Bitmap.LoadFromFile(ExpandConstant('{tmp}\button.bmp'))
  Image.Parent:=Panel
  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)        //Текст кнопок
  Labl.Left:=23                          //Указываем положение текста
  Labl.Top:=5
  Labl.Autosize:=True
  Labl.Alignment:=taCenter
  Labl.Tag:=AButtonIndex
  Labl.Transparent:=True
  Labl.Font.Color:=clWhite               //Цвет текста
  Labl.Caption:=AButton.Caption
  Labl.OnClick:=@ButtonLabelClick
  Labl.OnDblClick:=@ButtonLabelClick
  Labl.OnMouseDown:=@ButtonLabelMouseDown
  Labl.OnMouseUp:=@ButtonLabelMouseUp
  Labl.Parent:=Panel
  ButtonLabel[AButtonIndex]:=Labl
end;

procedure UpdateButton(AButton: TButton;AButtonIndex: integer);
begin
  ButtonLabel[AButtonIndex].Caption:=AButton.Caption
  ButtonPanel[AButtonIndex].Visible:=AButton.Visible
  ButtonLabel[AButtonIndex].Enabled:=Abutton.Enabled
end;

procedure LicenceAcceptedRadioOnClick(Sender: TObject);
begin
  ButtonLabel[bidNext].Enabled:=True
end;

procedure LicenceNotAcceptedRadioOnClick(Sender: TObject);
begin
  ButtonLabel[bidNext].Enabled:=False
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  UpdateButton(WizardForm.BackButton,bidBack)
  UpdateButton(WizardForm.NextButton,bidNext)
  UpdateButton(WizardForm.CancelButton,bidCancel)
end;

procedure InitializeWizard();
begin
  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:=337
  WizardForm.DirBrowseButton.Width:=ButtonWidth
  WizardForm.DirBrowseButton.Height:=ButtonHeight
  
  WizardForm.GroupBrowseButton.Left:=337
  WizardForm.GroupBrowseButton.Width:=ButtonWidth
  WizardForm.GroupBrowseButton.Height:=ButtonHeight
  
  WizardForm.LicenseAcceptedRadio.OnClick:=@LicenceAcceptedRadioOnClick

  WizardForm.LicenseNotAcceptedRadio.OnClick:=@LicenceNotAcceptedRadioOnClick

  ExtractTemporaryFile('button.bmp')
  LoadButtonImage(WizardForm.BackButton,bidBack)
  LoadButtonImage(WizardForm.NextButton,bidNext)
  LoadButtonImage(WizardForm.CancelButton,bidCancel)
  LoadButtonImage(WizardForm.DirBrowseButton,bidDirBrowse)
  LoadButtonImage(WizardForm.GroupBrowseButton,bidGroupBrowse)
end;
Это сообщение посчитали полезным следующие участники:

Отправлено: 17:31, 12-10-2009 | #224