KaFu Posted July 13, 2009 Share Posted July 13, 2009 (edited) Hiho Community, I want to assign a shell32.dll icon to a menu entry. Code posted below returns a sucess, but icon won't show up. Anyone got a hint for me? expandcollapse popup#include <GuiMenu.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <GDIPlus.au3> Global $iMemo _GDIPlus_Startup () _Main() _GDIPlus_Shutdown() Func _Main() Local $hGUI, $hFile, $hEdit, $hHelp, $hMain Local Enum $idNew = 1000, $idOpen, $idSave, $idExit, $idCut, $idCopy, $idPaste, $idAbout ; Create GUI $hGUI = GUICreate("Menu", 400, 300) ; Create File menu $hFile = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hFile, 0, "&New", $idNew) _GUICtrlMenu_InsertMenuItem ($hFile, 1, "&Open", $idOpen) _GUICtrlMenu_InsertMenuItem ($hFile, 2, "&Save", $idSave) _GUICtrlMenu_InsertMenuItem ($hFile, 3, "", 0) _GUICtrlMenu_InsertMenuItem ($hFile, 4, "E&xit", $idExit) ; Create Edit menu $hEdit = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hEdit, 0, "&Cut", $idCut) _GUICtrlMenu_InsertMenuItem ($hEdit, 1, "C&opy", $idCopy) _GUICtrlMenu_InsertMenuItem ($hEdit, 2, "&Paste", $idPaste) ; Create Help menu $hHelp = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hHelp, 0, "&About", $idAbout) ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hMain, 0, "&File", 0, $hFile) _GUICtrlMenu_InsertMenuItem ($hMain, 1, "&Edit", 0, $hEdit) _GUICtrlMenu_InsertMenuItem ($hMain, 2, "&Help", 0, $hHelp) ; Set window menu _GUICtrlMenu_SetMenu ($hGUI, $hMain) ; Create memo control $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() ; Set New menu item to have a bitmap MsgBox(0,"",_GUICtrlMenu_SetItemBmp($hFile, 1, _GDIPlus_BitmapCreateFromHBITMAP(_WinAPI_SHExtractIcons('shell32.dll',8,16,16)))) MemoWrite("Item bitmap handle: 0x" & Hex(_GUICtrlMenu_GetItemBmp ($hFile, 0))) ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Write message to memo Func MemoWrite($sMessage) GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Func _WinAPI_SHExtractIcons($sIcon, $iIndex, $iWidth, $iHeight) Local $Ret = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0) If (@error) Or ($Ret[0] = 0) Or ($Ret[5] = Ptr(0)) Then Return SetError(1, 0, 0) EndIf Return $Ret[5] EndFunc ;==>_WinAPI_SHExtractIcons Best Regards Edited July 13, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Yashied Posted July 13, 2009 Share Posted July 13, 2009 KaFu, look this.With the new search at the forum, has cost very hard me to find this post. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
KaFu Posted July 13, 2009 Author Share Posted July 13, 2009 With the new search at the forum, has cost very hard me to find this post. The problem was not the search itself but using the right keywords , thanks for your fast response, fully satisfies my need ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Yashied Posted July 13, 2009 Share Posted July 13, 2009 (edited) Previously, when I typed the keyword "Yashied", I got all the topics with my posts, and sorted default by date. Now I get 80% of garbage. Edited July 13, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... 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