picea892 Posted June 27, 2009 Share Posted June 27, 2009 (edited) Hi _GUIImageList_AddIcon($hImagebtn3, $iconlist[$i][4],1, False) When adding a icon to a imagelist or using it in any way you can use a default icon without risk of failure. However, if I want to use another icon in the exe (such as index 1) is there a way programatically to find out if it exists before I get the _GUIImageList_AddIcon: -1 error. Alternatively, is there away to suppress the error and thus give yourself the chance to try again with the default icon instead of crashing the script. Appreciate the help Picea Edited June 27, 2009 by picea892 Link to comment Share on other sites More sharing options...
Yashied Posted June 27, 2009 Share Posted June 27, 2009 This, without quitting the program. Returns (-1) if error occurred. Func __GUIImageList_AddIcon($hWnd, $sFile, $iIndex = 0, $fLarge = False) Local $tIcon, $iResult, $hIcon $tIcon = DllStructCreate("int Handle") If $fLarge Then $iResult = _WinAPI_ExtractIconEx($sFile, $iIndex, DllStructGetPtr($tIcon), 0, 1) Else $iResult = _WinAPI_ExtractIconEx($sFile, $iIndex, 0, DllStructGetPtr($tIcon), 1) EndIf If $iResult <= 0 Then Return SetError(1, 0, -1) EndIf $hIcon = DllStructGetData($tIcon, "Handle") $iResult = _GUIImageList_ReplaceIcon($hWnd, -1, $hIcon) DllCall('user32.dll', 'int', 'DestroyIcon', 'ptr', $hIcon) If $iResult = -1 Then Return SetError(1, 0, -1) EndIf Return $iResult EndFunc ;==>__GUIImageList_AddIcon 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...
picea892 Posted June 27, 2009 Author Share Posted June 27, 2009 Yashied that works like a charm. This is excellent! Thanks again for your help. I wish one day to help you....I doubt I ever will be able. I am certain there are others who have had this problem and never asked. At the very least by asking the question I have advanced the greater community. Picea 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