supersonic Posted June 4, 2009 Share Posted June 4, 2009 Hi, is it possible to use icons larger than 32x32 pixel with buttons created with GUICtrlCreateButton()? I'm looking for using icons NOT bitmaps... Greets, -supersonic. Link to comment Share on other sites More sharing options...
weaponx Posted June 4, 2009 Share Posted June 4, 2009 Did you look in the "user defined functions" in the help file? #Include <GuiButton.au3> _GUICtrlButton_SetImage($hWnd, $sImageFile[, $nIconId = -1[, $fLarge = False]]) Link to comment Share on other sites More sharing options...
supersonic Posted June 4, 2009 Author Share Posted June 4, 2009 Yes I did. When using "False" for $fLarge the icon is resized to 16x16. When using "True" the icon will be 32x32. Did you look in the "user defined functions" in the help file? #Include <GuiButton.au3> _GUICtrlButton_SetImage($hWnd, $sImageFile[, $nIconId = -1[, $fLarge = False]]) Link to comment Share on other sites More sharing options...
weaponx Posted June 4, 2009 Share Posted June 4, 2009 This code displays a 48x48 icon for me. #include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> GUICreate("Buttons", 300, 300) GUISetState() $btn = GUICtrlCreateButton("Button1", 10, 10, 64, 64, $BS_ICON) _GUICtrlButton_SetImage($btn, @DesktopDir & "\106.ico") While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Link to comment Share on other sites More sharing options...
supersonic Posted June 4, 2009 Author Share Posted June 4, 2009 You're right! :-) I forgot to mention that I'm trying to use embedded resources (#AutoIt3Wrapper_Res_Icon_Add=). #AutoIt3Wrapper_Res_Icon_Add=".\ico\update14.ico" _GUICtrlButton_SetImage($aTab3B1, @ScriptFullPath, 16)oÝ÷ Ø òײ«¨µéÚ Link to comment Share on other sites More sharing options...
weaponx Posted June 4, 2009 Share Posted June 4, 2009 I think there may be a problem in the call to _GUICtrlButton_SetImage when you specify the icon id to extract. In that function there is a call to _WinAPI_ExtractIconEx which always returns an error on an *.ico file. Link to comment Share on other sites More sharing options...
Yashied Posted June 4, 2009 Share Posted June 4, 2009 Replace _WinAPI_ExtractIconEx() at _WinAPI_PrivateExtractIcon() and it works.Func _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) Local $hIcon, $tIcon = DllStructCreate('hwnd'), $tID = DllStructCreate('hwnd') Local $Ret = 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) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf $hIcon = DllStructGetData($tIcon, 1) If ($hIcon = Ptr(0)) Or (Not IsPtr($hIcon)) Then Return SetError(1, 0, 0) EndIf Return $hIcon EndFunc ;==>_WinAPI_PrivateExtractIcon 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...
supersonic Posted June 5, 2009 Author Share Posted June 5, 2009 Thanks for the reply. :-) Please, can you give me an example how to implement this function? Replace _WinAPI_ExtractIconEx() at _WinAPI_PrivateExtractIcon() and it works. Func _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) Local $hIcon, $tIcon = DllStructCreate('hwnd'), $tID = DllStructCreate('hwnd') Local $Ret = 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) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf $hIcon = DllStructGetData($tIcon, 1) If ($hIcon = Ptr(0)) Or (Not IsPtr($hIcon)) Then Return SetError(1, 0, 0) EndIf Return $hIcon EndFunc ;==>_WinAPI_PrivateExtractIcon Link to comment Share on other sites More sharing options...
picea892 Posted June 5, 2009 Share Posted June 5, 2009 look up yashied's script in the examples. He give a couple of examples there. Link to comment Share on other sites More sharing options...
Yashied Posted June 5, 2009 Share Posted June 5, 2009 Try this. (I have not tried it) expandcollapse popup#Include <GUIConstantsEx.au3> #Include <GuiButton.au3> #Include <WindowsConstants.au3> GUICreate("Buttons", 300, 300) GUISetState() $btn = GUICtrlCreateButton("Button1", 10, 10, 64, 64, $BS_ICON) _GUICtrlButton_SetIcon($btn, @DesktopDir & "\106.ico", 0, 48, 48) While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func _GUICtrlButton_SetIcon($hWnd, $sIcon, $iIndex, $iWidth, $iHeight) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If $hWnd = 0 Then Return False EndIf EndIf Local $hIcon = _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) If @error Then Return False EndIf Local $hPrev = _SendMessage($hWnd, 0xF7, 1, $hIcon) If $hPrev Then If Not _WinAPI_DeleteObject($hPrev) Then _WinAPI_DestroyIcon($hPrev) EndIf EndIf _WinAPI_UpdateWindow($hWnd) Return True EndFunc ;==>_GUICtrlButton_SetIcon Func _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) Local $hIcon, $tIcon = DllStructCreate('hwnd'), $tID = DllStructCreate('hwnd') Local $Ret = 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) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf $hIcon = DllStructGetData($tIcon, 1) If ($hIcon = Ptr(0)) Or (Not IsPtr($hIcon)) Then Return SetError(1, 0, 0) EndIf Return $hIcon EndFunc ;==>_WinAPI_PrivateExtractIcon Parsix 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...
supersonic Posted June 5, 2009 Author Share Posted June 5, 2009 It work's! :-) Thank you soo much! Try this. (I have not tried it) expandcollapse popup#Include <GUIConstantsEx.au3> #Include <GuiButton.au3> #Include <WindowsConstants.au3> GUICreate("Buttons", 300, 300) GUISetState() $btn = GUICtrlCreateButton("Button1", 10, 10, 64, 64, $BS_ICON) _GUICtrlButton_SetIcon($btn, @DesktopDir & "\106.ico", 0, 48, 48) While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Func _GUICtrlButton_SetIcon($hWnd, $sIcon, $iIndex, $iWidth, $iHeight) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If $hWnd = 0 Then Return False EndIf EndIf Local $hIcon = _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) If @error Then Return False EndIf Local $hPrev = _SendMessage($hWnd, 0xF7, 1, $hIcon) If $hPrev Then If Not _WinAPI_DeleteObject($hPrev) Then _WinAPI_DestroyIcon($hPrev) EndIf EndIf _WinAPI_UpdateWindow($hWnd) Return True EndFunc ;==>_GUICtrlButton_SetIcon Func _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) Local $hIcon, $tIcon = DllStructCreate('hwnd'), $tID = DllStructCreate('hwnd') Local $Ret = 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) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf $hIcon = DllStructGetData($tIcon, 1) If ($hIcon = Ptr(0)) Or (Not IsPtr($hIcon)) Then Return SetError(1, 0, 0) EndIf Return $hIcon EndFunc ;==>_WinAPI_PrivateExtractIcon Link to comment Share on other sites More sharing options...
Yashied Posted June 5, 2009 Share Posted June 5, 2009 Your welcome. 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...
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