cyberbit Posted November 1, 2012 Posted November 1, 2012 Hi again. I'm trying to find a way to get the path and ID of an icon based on an icon handle, like something returned from WinAPI_ShellExtractAssociatedIcon. Is this even possible? Regards, Cyberbit _ArrayConcatenate2D · Aero Flip 3D · EPOCH (destroy timestamps) · File Properties Modifier · _GetFileType · UpdateEngine<new> · In-line Case (_ICase) <new> [hr] 50% of the time, it works all the time. -PezoFaSho
PhoenixXL Posted November 2, 2012 Posted November 2, 2012 (edited) look at _WinAPI_GetIconInfoEx in Edited November 2, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
cyberbit Posted November 2, 2012 Author Posted November 2, 2012 (edited) I've tried that, but it only works like this: $hInstance = _WinAPI_LoadLibraryEx(@AutoItExe, $LOAD_LIBRARY_AS_DATAFILE) $hIcon = _WinAPI_LoadImage($hInstance, 99, $IMAGE_ICON, 0, 0, $LR_DEFAULTSIZE) $aInfo = _WinAPI_GetIconInfoEx($hIcon) Alternatively, is is possible to set the icon of a GUI using a generic image/icon handle? Regards, Cyberbit Edited November 5, 2012 by cyberbit _ArrayConcatenate2D · Aero Flip 3D · EPOCH (destroy timestamps) · File Properties Modifier · _GetFileType · UpdateEngine<new> · In-line Case (_ICase) <new> [hr] 50% of the time, it works all the time. -PezoFaSho
PhoenixXL Posted November 3, 2012 Posted November 3, 2012 have a look at this example expandcollapse popup#NoTrayIcon #Include <APIConstants.au3> Opt('MustDeclareVars', 1) Global $hForm, $hParent $hParent = GUICreate('', 0, 0, 0, 0, 0, $WS_EX_TOOLWINDOW) $hForm = GUICreate('MyGUI', 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), BitOR($WS_EX_DLGMODALFRAME, $WS_EX_TOPMOST), $hParent) ; Remove window icon _WinAPI_SetClassLongEx($hForm, $GCL_HICONSM, 0) _WinAPI_SetClassLongEx($hForm, $GCL_HICON, 0) GUISetState() Do Until GUIGetMsg() = -3 ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_SetClassLongEx ; Description....: Replaces the specified value into the specified window belongs. ; Syntax.........: _WinAPI_SetClassLongEx ( $hWnd, $iIndex, $iNewLong ) ; Parameters.....: $hWnd - Handle to the window. ; $iIndex - The value to be replaced. This parameter can be one of the following values. ; ; $GCL_CBCLSEXTRA ; $GCL_CBWNDEXTRA ; $GCL_HBRBACKGROUND ; $GCL_HCURSOR ; $GCL_HICON ; $GCL_HICONSM ; $GCL_HMODULE ; $GCL_MENUNAME ; $GCL_STYLE ; $GCL_WNDPROC ; ; $iNewLong - The replacement value. ; Return values..: Success - The previous value. ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: None ; Related........: ; Link...........: @@MsdnLink@@ SetClassLong ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_SetClassLongEx($hWnd, $iIndex, $iNewLong) Local $Ret If @AutoItX64 Then $Ret = DllCall('user32.dll', 'ulong_ptr', 'SetClassLongPtrW', 'hwnd', $hWnd, 'int', $iIndex, 'long_ptr', $iNewLong) Else $Ret = DllCall('user32.dll', 'ulong', 'SetClassLongW', 'hwnd', $hWnd, 'int', $iIndex, 'long', $iNewLong) EndIf If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_WinAPI_SetClassLongEx My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
cyberbit Posted November 5, 2012 Author Posted November 5, 2012 Awesome. Works like a charm. While that works for a title, it still doesn't solve the Icon control issue. Would you recommend using the IconSave functions to write the image data to a temporary file then pulling that to a control? Regards, Cyberbit _ArrayConcatenate2D · Aero Flip 3D · EPOCH (destroy timestamps) · File Properties Modifier · _GetFileType · UpdateEngine<new> · In-line Case (_ICase) <new> [hr] 50% of the time, it works all the time. -PezoFaSho
PhoenixXL Posted November 5, 2012 Posted November 5, 2012 (edited) This shows saving the Icon #include <WinAPIEx.au3> #include <WindowsConstants.au3> #include <APIConstants.au3> Global $hForm, $hParent $hParent = GUICreate('', 0, 0, 0, 0, 0, $WS_EX_TOOLWINDOW) $hForm = GUICreate('MyGUI', 400, 400, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), BitOR($WS_EX_DLGMODALFRAME, $WS_EX_TOPMOST), $hParent) ; Get Icon Handle $hIcon = _WinAPI_GetClassLongEx($hForm, $GCL_HICONSM) ; Lets Save it _WinAPI_SaveHICONToFile(@ScriptDir&'Test.ico',$hIcon) ;Gone Fishing ;) If @error Then Exit @error ExitNext adding it to the control you can do that.. Edited November 5, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
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