Yashied Posted February 10, 2009 Share Posted February 10, 2009 If you have problems displaying large size (eg 128x128) icons from the *.exe files, take a look at _DrawIcon function which I use instead GUICtrlCreateIcon. expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #region Examle GUICreate('Test', 176, 88) GUICtrlCreateIcon('C:\WINDOWS\explorer.exe', 0, 108, 20, 48, 48) _DrawIcon('C:\WINDOWS\explorer.exe', 0, 20, 20, 48, 48) GUISetState() do Sleep(10) until GUIGetMsg() = $GUI_EVENT_CLOSE #endregion Example func _DrawIcon($sIcon, $iIndex, $iLeft, $iTop, $iWidth, $iHeight, $iStyle = -1, $iExStyle = -1) const $STM_SETIMAGE = 0x0172 local $iIcon, $hIcon, $tIcon, $tID local $bError = false $tIcon = DllStructCreate('hwnd') $tID = DllStructCreate('hwnd') DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0) if @error then $bError = 1 endif $hIcon = DllStructGetData($tIcon, 1) $tIcon = 0 $tID = 0 if ($bError) or (not IsPtr($hIcon)) then return SetError(1, 0, 0) endif $iIcon = GUICtrlCreateIcon('', 0, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) if $iIcon > 0 then GUICtrlSendMsg($iIcon, $STM_SETIMAGE, $IMAGE_ICON, _WinAPI_CopyIcon($hIcon)) endif _WinAPI_DeleteObject($hIcon) return SetError(0, 0, $iIcon) endfunc; _DrawIcon 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...
BigDod Posted February 10, 2009 Share Posted February 10, 2009 Should this not be in Example Scripts as it is not a request for support. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
martin Posted February 10, 2009 Share Posted February 10, 2009 If you have problems displaying large size (eg 128x128) icons from the *.exe files, take a look at _DrawIcon function which I use instead GUICtrlCreateIcon. expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #region Examle GUICreate('Test', 176, 88) GUICtrlCreateIcon('C:\WINDOWS\explorer.exe', 0, 108, 20, 48, 48) _DrawIcon('C:\WINDOWS\explorer.exe', 0, 20, 20, 48, 48) GUISetState() do Sleep(10) until GUIGetMsg() = $GUI_EVENT_CLOSE #endregion Example func _DrawIcon($sIcon, $iIndex, $iLeft, $iTop, $iWidth, $iHeight, $iStyle = -1, $iExStyle = -1) const $STM_SETIMAGE = 0x0172 local $iIcon, $hIcon, $tIcon, $tID local $bError = false $tIcon = DllStructCreate('hwnd') $tID = DllStructCreate('hwnd') DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0) if @error then $bError = 1 endif $hIcon = DllStructGetData($tIcon, 1) $tIcon = 0 $tID = 0 if ($bError) or (not IsPtr($hIcon)) then return SetError(1, 0, 0) endif $iIcon = GUICtrlCreateIcon('', 0, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) if $iIcon > 0 then GUICtrlSendMsg($iIcon, $STM_SETIMAGE, $IMAGE_ICON, _WinAPI_CopyIcon($hIcon)) endif _WinAPI_DeleteObject($hIcon) return SetError(0, 0, $iIcon) endfunc; _DrawIconThanks for that post Yashied! (When you have enough posts I think you should put it in example scripts.) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
DaRam Posted February 10, 2009 Share Posted February 10, 2009 Nice work with the _DrawCombineBkIcon also, Yashied. I am not seeing a benefit (display qualitywise) to your _DrawIcon Function using this code. Any thoughts? local $iconsrcexe = "C:\WINDOWS\explorer.exe" GUICreate(@scriptname, 1000, 500) local $sz, $left = 0 For $sz = 16 to 256 step 16 GUICtrlCreateIcon($iconsrcexe, 0, $left, 10, 80, $sz, $sz) _DrawIcon($iconsrcexe, 0, $left, 300, 80, $sz, $sz) $left += 80 Next;$sz GUISetState() do Sleep(10) until GUIGetMsg() = $GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
Yashied Posted February 10, 2009 Author Share Posted February 10, 2009 (edited) Nice work with the _DrawCombineBkIcon also, Yashied. I am not seeing a benefit (display qualitywise) to your _DrawIcon Function using this code. Any thoughts? local $iconsrcexe = "C:\WINDOWS\explorer.exe" GUICreate(@scriptname, 1000, 500) local $sz, $left = 0 For $sz = 16 to 256 step 16 GUICtrlCreateIcon($iconsrcexe, 0, $left, 10, 80, $sz, $sz) _DrawIcon($iconsrcexe, 0, $left, 300, 80, $sz, $sz) $left += 80 Next;$sz GUISetState() do Sleep(10) until GUIGetMsg() = $GUI_EVENT_CLOSE DaRam, look more closely at the title of function! _DrawIcon($sIcon, $iIndex, $iLeft, $iTop, $iWidth, $iHeight, $iStyle = -1, $iExStyle = -1) local $iconsrcexe = "C:\WINDOWS\explorer.exe" GUICreate(@scriptname, 1000, 500) local $sz, $left = 0 For $sz = 16 to 256 step 16 GUICtrlCreateIcon($iconsrcexe, 0, $left, 10, $sz, $sz) _DrawIcon($iconsrcexe, 0, $left, 300, $sz, $sz) $left += 80 Next;$sz GUISetState() do Sleep(10) until GUIGetMsg() = $GUI_EVENT_CLOSE Moreover, it is assumed that the icon size exists in the specified file. In any case, look at my screenshort. Edited May 12, 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...
Lazycat Posted February 11, 2009 Share Posted February 11, 2009 Nice simple way to get large icons. But it have a drawback - PrivateExtractIcons is deprecated function and can be removed in future. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) 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