Пользователь
Сообщения: 129
Благодарности: 76
Профиль
|
Отправить PM
| Цитировать
Serega , благодарю за желание помочь.
Я тоже нашёл неплохой вариант, адаптировал под свои нужды всем известный код, с текстурными кнопками.
Получилось вроде-бы не плохо.
И самое для меня главное, он должен работать в любой версии Inno
предлагаю взглянуть
Код:
; Inno Setup Compiler 5.3.5 (ansi & unicode)
; = Emulation of switching-off of style XP =
; http://forum.oszone.net/ <serg aka lain>
[Setup]
AppName=My Program
AppVerName=My Program
DefaultDirName={pf}\My Program
LicenseFile=compiler:License.txt
OutputDir=userdocs:My Program.
[code]
const
RGN_DIFF = 4;
RADIUS = 1;
bidBack = 0;
bidNext = 1;
bidCancel = 2;
bidDirBrowse = 3;
bidGroupBrowse = 4;
function CreateRoundRectRgn(p1, p2, p3, p4, p5, p6: Integer): THandle;
external 'CreateRoundRectRgn@gdi32 stdcall';
function CombineRgn(p1, p2, p3: THandle; p4: Integer): Integer;
external 'CombineRgn@gdi32 stdcall';
function SetWindowRgn(hWnd: HWND; hRgn: THandle; bRedraw: Boolean): Integer;
external 'SetWindowRgn@user32 stdcall';
var
FormRegion, InnerRegion: tHandle;
Panel: TPanel;
ButtonPanel: array [0..4] of TPanel;
ButtonLabel: array [0..4] of TLabel;
procedure ShapeForm(aForm : TForm; edgeSize : integer);
begin
FormRegion := CreateRoundRectRgn(0, 0, aForm.width, aForm.height, edgeSize, edgeSize);
CombineRgn(FormRegion, FormRegion, InnerRegion, RGN_DIFF);
SetWindowRgn(aForm.Handle, FormRegion, True);
end;
procedure ButtonLabelClick(Sender: TObject);
var
Button: TButton;
begin
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
ButtonPanel[TLabel(Sender).Tag].BorderStyle := bsSingle;
end;
procedure ButtonLabelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ButtonPanel[TLabel(Sender).Tag].BorderStyle := bsSizeable;
end;
procedure LabelMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
ButtonPanel[TLabel(Sender).Tag].BorderStyle := bsSizeable;
end;
procedure LoadButton(AButton: TButton; AButtonIndex: integer);
var
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.BorderStyle := bsSizeable;
Panel.Parent := AButton.Parent;
ButtonPanel[AButtonIndex] := Panel;
with TLabel.Create(WizardForm) do
begin
Width := Panel.Width;
Height := Panel.Height;
AutoSize := False;
Tag := AButtonIndex;
OnClick := @ButtonLabelClick;
OnDblClick := @ButtonLabelClick;
OnMouseDown := @ButtonLabelMouseDown;
OnMouseUp := @ButtonLabelMouseUp;
OnMouseMove := @LabelMouseMove;
TransParent := True;
Parent := Panel;
end;
Labl := TLabel.Create(WizardForm);
Labl.Width := Panel.Width - ScaleX(10);
Labl.Height := Panel.Height - ScaleY(10);
Labl.Alignment := taCenter;
Labl.Autosize := False;
Labl.Font.Color := clBlack;
Labl.Caption := AButton.Caption;
Labl.OnClick := @ButtonLabelClick;
Labl.OnDblClick := @ButtonLabelClick;
Labl.OnMouseDown := @ButtonLabelMouseDown;
Labl.OnMouseUp := @ButtonLabelMouseUp;
Labl.Cursor := crHand;
Labl.Tag := AButtonIndex;
Labl.Transparent := True;
ButtonLabel[AButtonIndex] := Labl;
Labl.Parent := Panel;
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 InitializeWizard();
begin
ShapeForm(WizardForm, RADIUS);
WizardForm.LicenseAcceptedRadio.OnClick := @LicenceAcceptedRadioOnClick;
WizardForm.LicenseNotAcceptedRadio.OnClick := @LicenceNotAcceptedRadioOnClick;
LoadButton(WizardForm.BackButton,bidBack);
LoadButton(WizardForm.NextButton,bidNext);
LoadButton(WizardForm.CancelButton,bidCancel);
LoadButton(WizardForm.DirBrowseButton,bidDirBrowse);
LoadButton(WizardForm.GroupBrowseButton,bidGroupBrowse);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
UpdateButton(WizardForm.BackButton,bidBack);
UpdateButton(WizardForm.NextButton,bidNext);
UpdateButton(WizardForm.CancelButton,bidCancel);
ButtonLabel[bidBack].Left := ButtonPanel[bidBack].Width div 2 - ButtonLabel[bidBack].Width div 2;
ButtonLabel[bidBack].Top := ButtonPanel[bidBack].Height div 2 - ButtonLabel[bidBack].Height div 2;
ButtonLabel[bidNext].Left := ButtonPanel[bidNext].Width div 2 - ButtonLabel[bidNext].Width div 2;
ButtonLabel[bidNext].Top := ButtonPanel[bidNext].Height div 2 - ButtonLabel[bidNext].Height div 2;
ButtonLabel[bidCancel].Left := ButtonPanel[bidCancel].Width div 2 - ButtonLabel[bidCancel].Width div 2;
ButtonLabel[bidCancel].Top := ButtonPanel[bidCancel].Height div 2 - ButtonLabel[bidCancel].Height div 2;
ButtonLabel[bidDirBrowse].Left := ButtonPanel[bidDirBrowse].Width div 2 - ButtonLabel[bidDirBrowse].Width div 2;
ButtonLabel[bidDirBrowse].Top := ButtonPanel[bidDirBrowse].Height div 2 - ButtonLabel[bidDirBrowse].Height div 2;
ButtonLabel[bidGroupBrowse].Left := ButtonPanel[bidGroupBrowse].Width div 2 - ButtonLabel[bidGroupBrowse].Width div 2;
ButtonLabel[bidGroupBrowse].Top := ButtonPanel[bidGroupBrowse].Height div 2 - ButtonLabel[bidGroupBrowse].Height div 2;
end;
Последний раз редактировалось serg aka lain, 18-10-2009 в 20:07 .
Это сообщение посчитали полезным следующие участники:
Отправлено : 19:54, 18-10-2009
| #297