本文介绍了在Inno Setup的上下文菜单中添加图标图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里使用脚本在Inno Setup页面上添加一些上下文菜单:
向Inno设置页面添加上下文菜单
I'm using the script here to add some context menu to my Inno Setup pages:
Adding context menu to Inno Setup page
是否可以将图标图像添加到每个菜单项?
is there any way to add an icon image to every menu item?
推荐答案
使用 SetMenuItemBitmaps
:
[Code]
const
IMAGE_BITMAP = 0;
LR_LOADFROMFILE = $10;
LR_CREATEDIBSECTION = $2000;
function LoadImage(
hInst: Integer; ImageName: string; ImageType: UINT; X, Y: Integer;
Flags: UINT): THandle; external '[email protected] stdcall';
function SetMenuItemBitmaps(
hMenu: THandle; uPosition: Cardinal; uFlags: Cardinal;
hBitmapUnchecked: THandle; hBitmapChecked: THandle): Boolean;
external '[email protected] stdcall';
procedure AddMenuItem(
Menu: THandle; Position: Integer; ID: Integer; Caption: string;
ImageFileName: string);
var
Bitmap: THandle;
begin
InsertMenu(Menu, Position, MF_BYPOSITION or MF_STRING, ID, Caption);
ExtractTemporaryFile(ImageFileName);
Bitmap := LoadImage(
0, ExpandConstant('{tmp}\') + ImageFileName, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE or LR_CREATEDIBSECTION);
SetMenuItemBitmaps(Menu, Position, MF_BYPOSITION, Bitmap, Bitmap);
end;
在向Inno Setup页面添加上下文菜单的代码中,使用AddMenuItem
而不是InsertMenu
调用:
Use the AddMenuItem
instead of InsertMenu
calls in the code from Adding context menu to Inno Setup page:
AddMenuItem(PopupMenu, 0, ID_MUTE, 'Mute', 'mute.bmp');
AddMenuItem(PopupMenu, 1, ID_STOP, 'Stop', 'stop.bmp');
以上内容显然假设您已将透明位图图像添加到安装程序中:
The above obviously assumes, that you have the transparent bitmap images added to the installer:
[Files]
Source: "mute.bmp"; Flags: dontcopy
Source: "stop.bmp"; Flags: dontcopy
我已经使用 PixelFormer 来创建透明的.bmp图像.
I've used PixelFormer to create the transparent .bmp images.
这篇关于在Inno Setup的上下文菜单中添加图标图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!