Автор: log1stable
Дата сообщения: 11.09.2011 16:24
VASYAKRN, попробуй [more=так]======================================
Inno Setup Faq. Текстурирование кнопок через botva2.dll
======================================
[Setup]
AppName=MyApp
AppVerName=MyApp
DefaultDirName={pf}\MyApp
[Files]
Source: botva2.dll; DestDir: {tmp}; Flags: dontcopy
Source: compiler:innocallback.dll; DestDir: {tmp}; Flags: dontcopy
Source: Button.png; DestDir: {tmp}; Flags: dontcopy
[code]
type
TButtonInfo = record ButtonName: array of TButton; Handle: array of HWND; Count: Integer; end;
TBtnEventProc = procedure(h:HWND);
const
BtnClickEventID = 1;
BtnMouseEnterEventID = 2;
BtnMouseLeaveEventID = 3;
BtnMouseMoveEventID = 4;
balLeft = 0;
balCenter = 1;
var
ButtonsBuff: TButtonInfo;
HCancelButton, HNextButton, HBackButton, HDirBrowseButton, HGroupBrowseButton: HWND;
function WrapBtnCallback(Callback: TBtnEventProc; ParamCount: Integer): Longword; external 'wrapcallback@files:innocallback.dll stdcall';
function BtnCreate(hParent:HWND; Left,Top,Width,Height:integer; FileName:PChar; ShadowWidth:integer; IsCheckBtn:boolean):HWND; external 'BtnCreate@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetPosition(h:HWND; NewLeft, NewTop, NewWidth, NewHeight: integer); external 'BtnSetPosition@files:botva2.dll stdcall';
procedure BtnRefresh(h:HWND); external 'BtnRefresh@files:botva2.dll stdcall';
function BtnGetChecked(h:HWND):boolean; external 'BtnGetChecked@files:botva2.dll stdcall';
procedure BtnSetChecked(h:HWND; Value:boolean); external 'BtnSetChecked@files:botva2.dll stdcall';
procedure BtnSetText(h:HWND; Text:PAnsiChar); external 'BtnSetText@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetTextAlignment(h:HWND; HorIndent, VertIndent:integer; Alignment:DWORD); external 'BtnSetTextAlignment@files:botva2.dll stdcall';
procedure BtnSetVisibility(h:HWND; Value:boolean); external 'BtnSetVisibility@files:botva2.dll stdcall';
function BtnGetEnabled(h:HWND):boolean; external 'BtnGetEnabled@files:botva2.dll stdcall';
procedure BtnSetEnabled(h:HWND; Value:boolean); external 'BtnSetEnabled@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetFont(h:HWND; Font:Cardinal); external 'BtnSetFont@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetFontColor(h:HWND; NormalFontColor, FocusedFontColor, PressedFontColor, DisabledFontColor: Cardinal); external 'BtnSetFontColor@{tmp}\botva2.dll stdcall delayload';
procedure BtnSetEvent(h:HWND; EventID:integer; Event:Longword); external 'BtnSetEvent@files:botva2.dll stdcall';
procedure BtnSetCursor(h:HWND; hCur:Cardinal); external 'BtnSetCursor@files:botva2.dll stdcall';
function GetSysCursorHandle(id:integer):Cardinal; external 'GetSysCursorHandle@files:botva2.dll stdcall';
procedure gdipShutdown; external 'gdipShutdown@files:botva2.dll stdcall';
procedure UpdateButtons();
var I: integer;
begin
for I:=0 to (ButtonsBuff.Count-1) do begin
BtnSetEnabled(ButtonsBuff.Handle[I], ButtonsBuff.ButtonName[I].Enabled)
BtnSetVisibility(ButtonsBuff.Handle[I], ButtonsBuff.ButtonName[I].Visible)
BtnSetText(ButtonsBuff.Handle[I], ButtonsBuff.ButtonName[I].Caption)
BtnRefresh(ButtonsBuff.Handle[I])
end;
end;
procedure ButtonOnClick(hBtn: HWND);
var Btn: TButton; I: Integer;
begin
for I:=0 to (ButtonsBuff.Count-1) do begin
if hBtn = ButtonsBuff.Handle[I] then Btn:= ButtonsBuff.ButtonName[I];
end;
Btn.OnClick(Btn)
UpdateButtons;
end;
function EffectTextureButton(Handle: HWND; Button: TButton; ImageName: PAnsiChar; ShadowWidth: Integer; EnterEvent, MoveEvent, LeaveEvent: TbtnEventProc): HWND;
begin
Result:=BtnCreate(Handle, Button.Left-8, Button.Top-8, Button.Width+16, Button.Height+16, ImageName, ShadowWidth, False) //Размеры подобраны для текущей текстуры
BtnSetEvent(Result, BtnClickEventID, WrapBtnCallback(@ButtonOnClick, 1))
if EnterEvent <> nil then BtnSetEvent(Result, BtnMouseEnterEventID, WrapBtnCallback(EnterEvent, 1));
if MoveEvent <> nil then BtnSetEvent(Result, BtnMouseMoveEventID, WrapBtnCallback(MoveEvent, 1));
if LeaveEvent <> nil then BtnSetEvent(Result, BtnMouseLeaveEventID, WrapBtnCallback(LeaveEvent, 1));
BtnSetFont(Result, Button.Font.Handle)
BtnSetText(Result, Button.Caption);
BtnSetVisibility(Result, Button.Visible);
BtnSetFontColor(Result,clBlack,clBlack,clBlack,clGray);
BtnSetCursor(Result,GetSysCursorHandle(32649));
Button.Width:=0; Button.Height:= 0;
SetArrayLength(ButtonsBuff.Handle, ButtonsBuff.Count+1);SetArrayLength(ButtonsBuff.ButtonName, ButtonsBuff.Count+1);
ButtonsBuff.ButtonName[ButtonsBuff.Count]:= Button; ButtonsBuff.Handle[ButtonsBuff.Count]:= Result;
ButtonsBuff.Count:= ButtonsBuff.Count+1;
end;
procedure ButtonChangeFont(ButtonHandle: HWND; Font: TFont; NormalColor, FocusedColor, PressedColor, DisabledColor: Cardinal);
begin
if Font <> nil then BtnSetFont(ButtonHandle, Font.Handle);
BtnSetFontColor(ButtonHandle, NormalColor, FocusedColor, PressedColor, DisabledColor)
end;
procedure InitializeWizard();
begin
ExtractTemporaryFile('Button.png')
HNextButton:= EffectTextureButton(WizardForm.Handle, WizardForm.NextButton, ExpandConstant('{tmp}\Button.png'), 18, nil, nil, nil)
HCancelButton:= EffectTextureButton(WizardForm.Handle, WizardForm.CancelButton, ExpandConstant('{tmp}\Button.png'), 18, nil, nil, nil)
HBackButton:= EffectTextureButton(WizardForm.Handle, WizardForm.BackButton, ExpandConstant('{tmp}\Button.png'), 18, nil, nil, nil)
HDirBrowseButton:= EffectTextureButton(WizardForm.Handle, WizardForm.DirBrowseButton, ExpandConstant('{tmp}\Button.png'), 18, nil, nil, nil)
HGroupBrowseButton:= EffectTextureButton(WizardForm.Handle, WizardForm.GroupBrowseButton, ExpandConstant('{tmp}\Button.png'), 18, nil, nil, nil)
end;
procedure CurPageChanged(CurPageId: Integer);
begin
UpdateButtons
end;
procedure DeinitializeSetup();
begin
gdipShutdown
end;
[/more]. Четыре кнопки(Normal, OnMouse, Pressed, Disabled) должны быть друг над другом на некотором расстоянии в картинке Button.png