Who Posted July 13, 2010 Share Posted July 13, 2010 I want to embed some icons into my AutoIT program then use them within the toolbar. However, the image list seems to not accept embedded icons that after compiling, the toolbar shows nothing. So what is the problem here ?#AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\filetype-blank.ico #include <GuiToolbar.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hGUI, $hToolbar, $hNormal $hGUI = GUICreate("Toolbar", 400, 300) $hToolbar = _GUICtrlToolbar_Create($hGUI) GUICtrlCreateIcon(@AutoItExe, -5, 40, 40, 16, 16) ;~ This works $hNormal = _GUIImageList_Create(16, 16) ;~ _GUIImageList_AddIcon($hNormal, @AutoItExe, -5) ;~ This doesn't work _GUIImageList_AddIcon($hNormal, "C:\Program Files\AutoIt3\Icons\filetype-blank.ico", 0) ;~ This works _GUICtrlToolbar_SetImageList($hToolbar, $hNormal) _GUICtrlToolbar_AddButton($hToolbar, 0, 0) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc Link to comment Share on other sites More sharing options...
Who Posted July 15, 2010 Author Share Posted July 15, 2010 Anybody, please Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 15, 2010 Share Posted July 15, 2010 An AutoIt exe has 4 icons, your script adds a fifth. The icons are 0-based, so normally there are 0 thru 3, you added index 4. This works fine: #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files\AutoIt3\Icons\filetype-blank.ico #include <GuiToolbar.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $hGUI, $hToolbar, $hNormal, $iIconCnt, $iIconIndex $hGUI = GUICreate("Toolbar", 400, 300) $hToolbar = _GUICtrlToolbar_Create($hGUI) GUICtrlCreateIcon(@AutoItExe, -5, 100, 100, 16, 16) ;~ This works $iIconCnt = _WinAPI_ExtractIconEx(@AutoItExe, -1, 0, 0, 1) ; Get count MsgBox(64, "Debug", "Icon count in file = " & $iIconCnt) $hNormal = _GUIImageList_Create(16, 16) For $i = 0 To $iIconCnt - 1 $iIconIndex = _GUIImageList_AddIcon($hNormal, @AutoItExe, $i) Next _GUICtrlToolbar_SetImageList($hToolbar, $hNormal) For $i = 0 To $iIconCnt _GUICtrlToolbar_AddButton($hToolbar, $i, $i) Next GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main Note the loop is 0 to $iIconCnt - 1. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Who Posted July 15, 2010 Author Share Posted July 15, 2010 Wow, that solved the problem but now I'm facing another problem : the toolbar doesn't show the transparency of the icons . Do you have any solution for this ? Link to comment Share on other sites More sharing options...
Yashied Posted July 15, 2010 Share Posted July 15, 2010 $hNormal = _GUIImageList_Create(16, 16, 5, 1) 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...
Who Posted July 15, 2010 Author Share Posted July 15, 2010 Thanks PsaltyDS & Yashied so much for your help!!! It's now all fine. Next time I will read the documentation more carefully 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