madflame991 Posted March 22, 2008 Share Posted March 22, 2008 (edited) I know this will work to set an image on a button $but_pic = GUICtrlCreateButton('test',20,20,64,64,$BS_BITMAP) GUICtrlSetImage($but_pic,$path) But how do I unset it??? Edited March 22, 2008 by madflame991 Game Game Gadget! - read about indie games, gadgets, chiptunes and demoscenesAssembly-like language interpreter and custom machine emulatorSuper Mario Screen Mate - official website or autoit forum pageCogut - Puzzle Game + Editor like sokoban and others Link to comment Share on other sites More sharing options...
Aceguy Posted March 22, 2008 Share Posted March 22, 2008 $but_pic = GUICtrlCreateButton('test',20,20,64,64,$BS_BITMAP) GUICtrlSetImage($but_pic,-1) untested [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
madflame991 Posted March 22, 2008 Author Share Posted March 22, 2008 that didn't worked, thx for trying Game Game Gadget! - read about indie games, gadgets, chiptunes and demoscenesAssembly-like language interpreter and custom machine emulatorSuper Mario Screen Mate - official website or autoit forum pageCogut - Puzzle Game + Editor like sokoban and others Link to comment Share on other sites More sharing options...
Swift Posted March 22, 2008 Share Posted March 22, 2008 GUICtrlDelete($but_Pic) Link to comment Share on other sites More sharing options...
rover Posted March 22, 2008 Share Posted March 22, 2008 (edited) a little demo stick with the GUICtrlSetStyle() function method Edit: added GUICtrlSetState($Objects, $GUI_ENABLE) to $StyleON added missing function _GUICtrlButton_GetImage() (from GuiButton.au3) for 3.2.10.0 compatibility expandcollapse popup; Demo works in 3.2.10.0 and up (beta) ; BM_GETIMAGE constant needed for 3.2.10.0 ; uses GUIButton management UDF's in beta ; replace bmp file with your own #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <SendMessage.au3> ;#include <GuiButton.au3> ; v3.2.11.0 and up ;Global Const $BM_GETIMAGE = 0xF6 ; included in ButtonConstants.au3 for 3.2.11.0 and up Opt("GUIOnEventMode", 1) Local $btn, $chk, $rdo, $Msg Local $sPath = @WindowsDir & "\pchealth\helpctr\System\images\48x48\desktop_icon_01.bmp" Local $hgui = GUICreate("Delete bitmap/icon - Change style", 300, 200) ;GUISetBkColor(0xFFFFFF) GUISetOnEvent($GUI_EVENT_CLOSE, "_Events") GUISetState() $Objects = GUICtrlCreateButton("Remove Bitmap/Icon", 10, 80, 120, 30) GUICtrlSetOnEvent(-1, "_Events") GUICtrlCreateLabel("Bitmap or Icon style remains", 150, 88, 140, 30) $StyleOFF = GUICtrlCreateButton("Button style OFF", 10, 120, 120, 30) GUICtrlSetOnEvent(-1, "_Events") GUICtrlCreateLabel("Default styles set, text shown", 150, 128, 140, 30) $StyleON = GUICtrlCreateButton("Button style ON", 10, 160, 120, 30) GUICtrlSetOnEvent(-1, "_Events") GUICtrlCreateLabel("Bitmap/Icon styles set, text hidden", 150, 168, 140, 30) $btn = GUICtrlCreateButton("Button1", 10, 10, 50, 50, $BS_BITMAP) GUICtrlSetImage(-1, $sPath) ;_GUICtrlButton_SetImage($btn, $sPath) ; v3.2.11.0 and up GUICtrlSetOnEvent(-1, "_Events") $chk = GUICtrlCreateCheckbox("Check1", 70, 10, 55, 32, $BS_ICON) GUICtrlSetImage($chk, "shell32.dll", 14, True) ;_GUICtrlButton_SetImage($chk, "shell32.dll", 14, True) ; v3.2.11.0 and up GUICtrlSetOnEvent(-1, "_Events") $rdo = GUICtrlCreateRadio("Radio1", 140, 10, 50, 32, $BS_ICON) GUICtrlSetImage($rdo, "shell32.dll", 21, True) ;_GUICtrlButton_SetImage($rdo, "shell32.dll", 21, True) ; v3.2.11.0 and up GUICtrlSetOnEvent(-1, "_Events") While 1 Sleep(10000) WEnd Func _Events() Switch @GUI_CtrlId Case $Objects ; delete bitmap/icon, style remains $BS_BITMAP and $BS_ICON, no text on buttons _WinAPI_DeleteObject(_GUICtrlButton_GetImage(GUICtrlGetHandle($btn))) ; delete bitmap _WinAPI_InvalidateRect(GUICtrlGetHandle($btn), 0, True) ; repaint control _WinAPI_DestroyIcon(_GUICtrlButton_GetImage(GUICtrlGetHandle($chk))) ; delete icon _WinAPI_InvalidateRect(GUICtrlGetHandle($chk), 0, True) ; repaint control _WinAPI_DestroyIcon(_GUICtrlButton_GetImage(GUICtrlGetHandle($rdo))) ; delete icon _WinAPI_InvalidateRect(GUICtrlGetHandle($rdo), 0, True) ; repaint control GUICtrlSetState($Objects, $GUI_DISABLE) GUICtrlSetState($StyleON, $GUI_DISABLE) Case $StyleOFF ; reset button styles to default GUICtrlSetStyle($btn, $GUI_SS_DEFAULT_BUTTON) ; _GUICtrlButton_SetStyle($hWnd, $iStyle) v3.2.11.0 and up GUICtrlSetStyle($chk, $BS_AUTOCHECKBOX) GUICtrlSetStyle($rdo, $BS_AUTORADIOBUTTON) GUICtrlSetState($Objects, $GUI_DISABLE) Case $StyleON GUICtrlSetStyle($btn, $BS_BITMAP) GUICtrlSetStyle($chk, BitOR($BS_AUTOCHECKBOX, $BS_ICON)) GUICtrlSetStyle($rdo, BitOR($BS_AUTORADIOBUTTON, $BS_ICON)) GUICtrlSetState($Objects, $GUI_ENABLE) Case $btn Case $chk Case $rdo Case $GUI_EVENT_CLOSE Exit EndSwitch EndFunc ;==>_Events ; taken from beta v3.2.11.3 #include <GuiButton.au3> Func _GUICtrlButton_GetImage($hWnd) ; v3.2.11.0 and up If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $iResult = _SendMessage($hWnd, $BM_GETIMAGE, 0, 0, 0, "wparam", "lparam", "hwnd") ; check IMAGE_BITMAP If $iResult <> 0x00000000 Then Return $iResult $iResult = _SendMessage($hWnd, $BM_GETIMAGE, 1, 0, 0, "wparam", "lparam", "hwnd") ; check IMAGE_ICON If $iResult = 0x00000000 Then Return 0 Return $iResult EndFunc ;==>_GUICtrlButton_GetImage Edited March 23, 2008 by rover I see fascists... Link to comment Share on other sites More sharing options...
madflame991 Posted March 23, 2008 Author Share Posted March 23, 2008 garvy! it worked, thx! Game Game Gadget! - read about indie games, gadgets, chiptunes and demoscenesAssembly-like language interpreter and custom machine emulatorSuper Mario Screen Mate - official website or autoit forum pageCogut - Puzzle Game + Editor like sokoban and others 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