如何在 Inno Setup 中创建图像按钮?
How to create an image button in Inno Setup?
是否可以在 Inno Wizard 页面中使用图像按钮来代替普通的标题文本?
我想要完成的是创建一个 Off/On 图像按钮到 mute/play 音乐,而 Inno 设置是 运行。
谢谢!
在 Inno Setup 中不直接支持为按钮设置图像。
所以你必须恢复到 Win32 API。
function LoadImage(hInst: Integer; ImageName: string; ImageType: UINT;
X, Y: Integer; Flags: UINT): THandle;
external 'LoadImageW@User32.dll stdcall';
function ImageList_Add(ImageList: THandle; Image, Mask: THandle): Integer;
external 'ImageList_Add@Comctl32.dll stdcall';
function ImageList_Create(CX, CY: Integer; Flags: UINT;
Initial, Grow: Integer): THandle;
external 'ImageList_Create@Comctl32.dll stdcall';
const
IMAGE_BITMAP = 0;
LR_LOADFROMFILE = ;
ILC_COLOR32 = ;
BCM_SETIMAGELIST = 00 + [=10=]02;
type
BUTTON_IMAGELIST = record
himl: THandle;
margin: TRect;
uAlign: UINT;
end;
function SendSetImageListMessage(
Wnd: THandle; Msg: Cardinal; WParam: Cardinal;
var LParam: BUTTON_IMAGELIST): Cardinal;
external 'SendMessageW@User32.dll stdcall';
function InitializeSetup(): Boolean;
var
ImageList: THandle;
Image: THandle;
ButtonImageList: BUTTON_IMAGELIST;
begin
ImageList := ImageList_Create(16, 16, ILC_COLOR32, 1, 1);
Image := LoadImage(0, 'button.bmp', IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
ImageList_Add(ImageList, Image, 0);
ButtonImageList.himl := ImageList;
SendSetImageListMessage(
WizardForm.NextButton.Handle, BCM_SETIMAGELIST, 0, ButtonImageList);
end;
是否可以在 Inno Wizard 页面中使用图像按钮来代替普通的标题文本?
我想要完成的是创建一个 Off/On 图像按钮到 mute/play 音乐,而 Inno 设置是 运行。
谢谢!
在 Inno Setup 中不直接支持为按钮设置图像。
所以你必须恢复到 Win32 API。
function LoadImage(hInst: Integer; ImageName: string; ImageType: UINT;
X, Y: Integer; Flags: UINT): THandle;
external 'LoadImageW@User32.dll stdcall';
function ImageList_Add(ImageList: THandle; Image, Mask: THandle): Integer;
external 'ImageList_Add@Comctl32.dll stdcall';
function ImageList_Create(CX, CY: Integer; Flags: UINT;
Initial, Grow: Integer): THandle;
external 'ImageList_Create@Comctl32.dll stdcall';
const
IMAGE_BITMAP = 0;
LR_LOADFROMFILE = ;
ILC_COLOR32 = ;
BCM_SETIMAGELIST = 00 + [=10=]02;
type
BUTTON_IMAGELIST = record
himl: THandle;
margin: TRect;
uAlign: UINT;
end;
function SendSetImageListMessage(
Wnd: THandle; Msg: Cardinal; WParam: Cardinal;
var LParam: BUTTON_IMAGELIST): Cardinal;
external 'SendMessageW@User32.dll stdcall';
function InitializeSetup(): Boolean;
var
ImageList: THandle;
Image: THandle;
ButtonImageList: BUTTON_IMAGELIST;
begin
ImageList := ImageList_Create(16, 16, ILC_COLOR32, 1, 1);
Image := LoadImage(0, 'button.bmp', IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
ImageList_Add(ImageList, Image, 0);
ButtonImageList.himl := ImageList;
SendSetImageListMessage(
WizardForm.NextButton.Handle, BCM_SETIMAGELIST, 0, ButtonImageList);
end;