Search the Community
Showing results for tags 'icon exe shell'.
-
These functions I created to set the icon of GUICtrlCreateIcon using a filepath's icon. For example if you pass the file location of the script file (@ScriptFullPath), then the icon that will be displayed is the icon that is displayed in Windows Explorer, for me this is Notepad. Please see below for more details. Thanks. Example use of Functions: #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WinAPIShellEx.au3> Example() Func Example() Local $hGUI = GUICreate('', 128, 128) Local $iIcon = GUICtrlCreateIcon('', 0, 48, 48, 32, 32) ; Set the icon GUICtrlCreateIcon() using the @AutoItExe icon. _Icon_Set(-1, @AutoItExe) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Clear the GUICtrlCreateIcon() icon. _Icon_Clear($iIcon) ; Delete the GUI. GUIDelete($hGUI) EndFunc ;==>Example Func _Icon_Clear($iCtrlID) ; Returns True or False Local Const $STM_SETIMAGE = 0x0172 If $iCtrlID = Default Or $iCtrlID <= 0 Or Not IsInt($iCtrlID) Then $iCtrlID = _WinAPI_GetDlgCtrlID(GUICtrlGetHandle($iCtrlID)) EndIf Return _WinAPI_DestroyIcon(GUICtrlSendMsg($iCtrlID, $STM_SETIMAGE, $IMAGE_ICON, 0)) EndFunc ;==>_Icon_Clear Func _Icon_Set($iCtrlID, $sFilePath) ; Returns True or False Local Const $STM_SETIMAGE = 0x0172 If $iCtrlID = Default Or $iCtrlID <= 0 Or Not IsInt($iCtrlID) Then $iCtrlID = _WinAPI_GetDlgCtrlID(GUICtrlGetHandle($iCtrlID)) EndIf Local $fReturn = False If FileExists($sFilePath) Then Local $tFILEINFO = DllStructCreate($tagSHFILEINFO) _WinAPI_ShellGetFileInfo($sFilePath, BitOR($SHGFI_ICON, $SHGFI_LARGEICON), 0, $tFILEINFO) Local $hIcon = DllStructGetData($tFILEINFO, 'hIcon') $fReturn = _WinAPI_DestroyIcon(GUICtrlSendMsg($iCtrlID, $STM_SETIMAGE, $IMAGE_ICON, $hIcon)) EndIf Return $fReturn EndFunc ;==>_Icon_Set