简体   繁体   English

C ++:第1步:ExtractIconEx。 第2步: ??? 第3步:SetMenuItemBitmaps

[英]C++: Step 1: ExtractIconEx. Step 2: ??? Step 3: SetMenuItemBitmaps

I'm experimenting with adding icons to a shell extension. 我正在尝试向shell扩展添加图标。 I have this code (sanitized for easy reading), which works: 我有这个代码(清理易于阅读),它的工作原理如下:

InsertMenu(hmenu, index, MF_POPUP|MF_BYPOSITION, (UINT)hParentMenu, namestring);

The next step is this code: 下一步是这段代码:

HICON hIconLarge, hIconSmall;
ICONINFO oIconInfo;
ExtractIconEx("c:\\progra~1\\winzip\\winzip32.exe", 0, &hIconLarge, &hIconSmall, 1);
GetIconInfo(hIconSmall, &oIconInfo);
//???????
SetMenuItemBitmaps(hParentMenu, indexMenu-1, MF_BITMAP | MF_BYPOSITION, hbmp, hbmp);

What do I put in to replace the ?'s. 我该怎么做才能取代? Attempts to Google this knowledge have found many tips that I failed to get working. 尝试谷歌这一知识已经找到许多我没能工作的提示。 Any advice on getting this to work, especially on older machines (eg no .net framework, no vista) is appreciated. 任何关于让它工作的建议,特别是在较旧的机器上(例如没有.net框架,没有远景)都值得赞赏。

This works, though the back color is black instead of transparent. 这是有效的,虽然背面颜色是黑色而不是透明。

GetIconInfo(hIconSmall, &oIconInfo);
SetMenuItemBitmaps(hmenu, uMenuIndex+i+popUpMenuCount-1, MF_BITMAP | MF_BYPOSITION, oIconInfo.hbmColor, oIconInfo.hbmColor);

Vista has proper support for icons in menus, for pre Vista, you must use owner draw menu items (MF_OWNERDRAW) if you want real 16x16 full color icons Vista对菜单中的图标有适当的支持,对于Vista之前,如果你想要真正的16x16全彩图标,你必须使用所有者绘制菜单项(MF_OWNERDRAW)

Vista style menus... Vista style+pre Vista callback Vista风格的菜单...... Vista风格+ Vista之前的回调

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM