this-is-me Posted February 21, 2014 Share Posted February 21, 2014 I am trying to add an overlay to a small icon. I am wanting to add the UAC overlay to the bottom right of the icon as seen in the below example: However, with the code I have, I get this result: My (basic) example code: #include <GuiMenu.au3> #include <WinAPIGdi.au3> #include <WinAPIRes.au3> #NoTrayIcon Opt('TrayMenuMode', 3) Local $hMenu = TrayItemGetHandle(0) Local $Options = TrayCreateItem('Command Prompt Here (Administrator)') TrayCreateItem('') Local $Exit = TrayCreateItem('Exit') Local $hIconCmd = _WinAPI_ExtractIcon("cmd.exe", 0, True) Local $hIconUAC = _WinAPI_ExtractIcon("imageres.dll", 1, True) Local $hNewIcon = _WinAPI_AddIconOverlay($hIconCmd, $hIconUAC) _GUICtrlMenu_SetItemBmp($hMenu, 0, _WinAPI_Create32BitHBITMAP($hNewIcon, 1, 1)) TraySetState() TrayTip("Information", "Check out tray menu", 30) Do Until TrayGetMsg() = $Exit Is this a bug in _WinAPI_AddIconOverlay or is it a problem with the way I am calling the function? Who else would I be? Link to comment Share on other sites More sharing options...
LarsJ Posted February 22, 2014 Share Posted February 22, 2014 This is not a bug in _WinAPI_AddIconOverlay. _WinAPI_AddIconOverlay can only add an existing overlay icon to an icon. E.g. icon #154 in imageres.dll as is used in the example in the help file. It does not create new (small) overlay icons. You can see the icons in imageres.dll here.As far as I know this UAC shield overlay icon is handled different than other overlay icons. E.g. it's not included in imageres.dll as the other. This also means that you can't use _WinAPI_AddIconOverlay to add this overlay icon.A workaround is to replace an existing overlay icon in the system image list with your own overlay icon. Or replace an existing overlay icon in imageres.dll with your own. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
this-is-me Posted February 22, 2014 Author Share Posted February 22, 2014 Thanks for the detailed explanation. I understand completely now, and will go about making the UAC icon into an overlay myself. Thanks again for your help. Who else would I be? Link to comment Share on other sites More sharing options...
this-is-me Posted February 22, 2014 Author Share Posted February 22, 2014 For anyone else who would like to use it, I have created a UAC overlay icon that can be used.UACOverlay.ico Who else would I be? Link to comment Share on other sites More sharing options...
UEZ Posted February 23, 2014 Share Posted February 23, 2014 (edited) Try this line instead using your icon file: Local $hIconUAC = _WinAPI_LoadImage(0, @ScriptDir & "\UACOverlay.ico", $IMAGE_ICON, 0, 0, $LR_LOADFROMFILE) Br, UEZ Edited February 23, 2014 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
this-is-me Posted February 23, 2014 Author Share Posted February 23, 2014 (edited) UEZ, Is _WinAPI_LoadImage generally preferred over _WinAPI_ExtractIcon when the file is an icon only? If so, why? EDIT: Nevermind, I see that it has to do with the size of an icon on a menu, in general. _WinAPI_LoadImage would allow a person to respect the user's choice for icon size in menus, am I correct? Edited February 23, 2014 by this-is-me Who else would I be? Link to comment Share on other sites More sharing options...
UEZ Posted February 23, 2014 Share Posted February 23, 2014 Well, there a lot of ways to extract/load an icon from different sources. Some of the functions have different purposes than others. I personally prefer to use GDI+ rather than GDI. _WinAPI_LoadImage() is more flexible than _WinAPI_ExtractIcon() loading graphic files but important is the result. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now