innonewbie
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору [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.Font.Style := [fsBold]; //стиль текста 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 ButtonLabel[AButtonIndex].Left := ButtonPanel[AButtonIndex].Width div 2 - ButtonLabel[AButtonIndex].Width div 2; ButtonLabel[AButtonIndex].Top := ButtonPanel[AButtonIndex].Height div 2 - ButtonLabel[AButtonIndex].Height div 2; end; procedure LicenceAcceptedRadioOnClick(Sender: TObject); begin ButtonLabel[bidNext].Enabled:=True end; procedure LicenceNotAcceptedRadioOnClick(Sender: TObject); begin ButtonLabel[bidNext].Enabled:=False 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; procedure CurPageChanged(CurPageID: Integer); begin UpdateButton(WizardForm.BackButton,bidBack) UpdateButton(WizardForm.NextButton,bidNext) UpdateButton(WizardForm.CancelButton,bidCancel) end; |