bartveg Posted October 17, 2007 Share Posted October 17, 2007 Hi, I'm trying to create a button with an icon and text. I'm using the following code: $correctbutton = GUICtrlCreateButton("OK!", 257, 150, 200, 40) GUICtrlSetImage (-1, "shell32.dll",22) It does only display the icon and in Windows XP the button is also in 'classic style'. Can someone please tell me how I can make this working?? Tnx Bart Link to comment Share on other sites More sharing options...
ValeryVal Posted October 17, 2007 Share Posted October 17, 2007 You can add tip to it after GUICtrlSetImage (-1, "shell32.dll",22) write GUICtrlSetTip (-1, "It's OK!") This will work in any case. The point of world view Link to comment Share on other sites More sharing options...
bartveg Posted October 17, 2007 Author Share Posted October 17, 2007 That's not what I mean, I want the text on the button not in a Tip Link to comment Share on other sites More sharing options...
smashly Posted October 17, 2007 Share Posted October 17, 2007 (edited) Hi, #include <GuiConstants.au3> $Gui = GUICreate(" ;-)", 72, 90, -1, -1, -1, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $icon = GUICtrlCreateIcon("shell32.dll", -22, 19, 19, 32, 32) GUICtrlSetState(-1, $GUI_DISABLE) $button = GUICtrlCreateButton("Control Panel", 10, 10, 52, 70, BitOr($WS_CLIPSIBLINGS, $BS_BOTTOM, $BS_MULTILINE)) GUICtrlSetFont(-1, 8, 700) GUISetState(@SW_SHOW, $Gui) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button ShellExecute("control.exe") EndSelect WEnd Cheers Edited October 17, 2007 by smashly Link to comment Share on other sites More sharing options...
martin Posted October 18, 2007 Share Posted October 18, 2007 (edited) Hi, #include <GuiConstants.au3> $Gui = GUICreate(" ;-)", 72, 90, -1, -1, -1, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $icon = GUICtrlCreateIcon("shell32.dll", -22, 19, 19, 32, 32) GUICtrlSetState(-1, $GUI_DISABLE) $button = GUICtrlCreateButton("Control Panel", 10, 10, 52, 70, BitOr($WS_CLIPSIBLINGS, $BS_BOTTOM, $BS_MULTILINE)) GUICtrlSetFont(-1, 8, 700) GUISetState(@SW_SHOW, $Gui) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button ShellExecute("control.exe") EndSelect WEnd Cheers That's really a neat trick smashly, I like that a lot. I've made the icon move when the button is pressed. expandcollapse popup;from smashly #include <GuiConstants.au3> Dim $button[3],$icon[3],$icondown[3],$label[3] Global $ix = 21,$iy = 14 $Gui = GUICreate(";-)", 140, 80, -1, -1, -1, $WS_EX_TOOLWINDOW) $icon[0] = GUICtrlCreateIcon("shell32.dll", -22, 21, 14, 16, 16) GUICtrlSetState(-1, $GUI_DISABLE) $label[0] = guictrlcreatelabel('F8',21,29,20,12) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 8, 700) $button[0] = GUICtrlCreateButton("", 10, 10, 35, 35, BitOR($WS_CLIPSIBLINGS, $BS_BOTTOM, $BS_MULTILINE)) GUICtrlSetFont(-1, 8, 700) $icon[1] = GUICtrlCreateIcon("shell32.dll", -23, 61, 14, 16, 16) GUICtrlSetState(-1, $GUI_DISABLE) $label[1] = guictrlcreatelabel('F9',61,29,20,12) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 8, 700) $button[1] = GUICtrlCreateButton("", 50, 10, 35, 35, BitOR($WS_CLIPSIBLINGS, $BS_BOTTOM, $BS_MULTILINE)) GUICtrlSetFont(-1, 8, 700) $icon[2] = GUICtrlCreateIcon("shell32.dll", -24, 101, 14, 16, 16) GUICtrlSetState(-1, $GUI_DISABLE) $label[2] = guictrlcreatelabel('F10',101,29,20,12) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 8, 700) $button[2] = GUICtrlCreateButton("", 90, 10, 35, 35, BitOR($WS_CLIPSIBLINGS, $BS_BOTTOM, $BS_MULTILINE)) GUICtrlSetFont(-1, 8, 700) GUISetState(@SW_SHOW, $Gui) for $n = 0 to 2 $icondown[$n] = false Next While 1 for $nb = 0 to 2 CheckButton($icondown,$nb);added by martin Next $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button[0] ShellExecute("control.exe") Case $msg = $button[1] msgbox(8192,'button','No 2 pressed') Case $msg = $button[2] msgbox(8192,'button','No 3 pressed') ; EndSelect WEnd Func CheckButton(ByRef $ip,$abut); Local $bt = $button[$abut],$ic = $icon[$abut],$lb = $label[$abut] Local $ix = 21 + $abut*40,$iy = 14 $MP = GUIGetCursorInfo($Gui) If Not $MP[2] Then;left mouse button is not pressed If $ip[$abut] Then GUICtrlSetPos($ic, $ix , $iy) GUICtrlSetPos($lb, $ix , $iy + 15) EndIf $ip[$abut] = false Return EndIf ;left mouse button is pressed ;if mouse over icon or button If ($MP[4] = $ic Or $MP[4] = $bt or $MP[4] = $lb) And not $ip[$abut] Then GUICtrlSetPos($ic, $ix + 1, $iy + 1) GUICtrlSetPos($lb, $ix + 1, $iy + 16) $ip[$abut] = true guictrlsetstate($bt,$GUI_FOCUS) Else If $ip[$abut] And $MP[4] <> $ic And $MP[4] <> $bt and $mp[4] <> $lb Then GUICtrlSetPos($ic, $ix , $iy) GUICtrlSetPos($lb, $ix , $iy + 15) $ip[$abut] = false EndIf EndIf EndFunc ;==>CheckButton EDIT: changed to have 3 buttons instead of 1 Edited October 18, 2007 by martin 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...
star2 Posted December 24, 2007 Share Posted December 24, 2007 Hi, #include <GuiConstants.au3> $Gui = GUICreate(" ;-)", 72, 90, -1, -1, -1, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $icon = GUICtrlCreateIcon("shell32.dll", -22, 19, 19, 32, 32) GUICtrlSetState(-1, $GUI_DISABLE) $button = GUICtrlCreateButton("Control Panel", 10, 10, 52, 70, BitOr($WS_CLIPSIBLINGS, $BS_BOTTOM, $BS_MULTILINE)) GUICtrlSetFont(-1, 8, 700) GUISetState(@SW_SHOW, $Gui) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button ShellExecute("control.exe") EndSelect WEndoÝ÷ Ø(^z»?ªê-y«¢+Ø¥¹±Õ±ÐíÕ¥ ½¹ÍѹÑ̹ÔÌÐì((ÀÌØíÕ¤ôU% ÉÑ ÅÕ½Ðìì´¤ÅÕ½Ðì°ÄÈÔ°ÔÀ¤(ÀÌØí¥½¸ôU% Ñɱ ÉÑ%½¸ ÅÕ½ÐíÍ¡±°Ìȹ±°ÅÕ½Ðì°´ÈÈ°äÀ°ÄÜ°ÄØ°Äؤ)U% ÑɱMÑMÑÑ ´Ä°ÀÌØíU%}%M 1¤(ÀÌØíÕÑѽ¸ôU% Ñɱ ÉÑ ÕÑѽ¸ ÅÕ½Ðì ½¹Ñɽ°A¹°ÅÕ½Ðì°ÄÀ°ÄÀ°ÄÀÔ°ÌÀ°ÀÌØí]M} 1%AM% 1%9L¬ÀÌØí M}1P¤)U%MÑMÑÑ¡M]}M!=°ÀÌØíÕ¤¤()]¡¥±Ä(ÀÌØíµÍôU%Ñ5Í ¤(M±Ð( ÍÀÌØíµÍôÀÌØíU%}Y9Q} 1=M(á¥Ð( ÍÀÌØíµÍôÀÌØíÕÑѽ¸(M¡±±áÕÑ ÅÕ½Ðí½¹Ñɽ°¹áÅÕ½Ðì¤(¹M±Ð)]¹ I really liked the trick !!! [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
ValeryVal Posted December 25, 2007 Share Posted December 25, 2007 This one is more marvelous: #include <GuiConstants.au3> $Gui = GUICreate(";-)", 125, 50) ; Try to uncomment this ;$icon = GUICtrlCreateIcon("shell32.dll", -22, 90, 17, 16, 16) GUICtrlSetState(-1, $GUI_DISABLE) $button = GUICtrlCreateButton(" Control Panel", 10, 10, 105, 30, $WS_CLIPSIBLINGS + $BS_LEFT) $icon = GUICtrlCreateIcon("shell32.dll", -25, 90, 17, 16, 16) GUISetState(@SW_SHOW, $Gui) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button ShellExecute("control.exe") EndSelect WEnd Try uncomment and comment line #4! The point of world view Link to comment Share on other sites More sharing options...
copyleft Posted December 27, 2007 Share Posted December 27, 2007 (edited) Of the examples given, Smashly's seems to execute the fastest on my pc. However, how do you add another button to the dialog window to execute, say notepad.exe in the sample script, below: CODE#include <GuiConstants.au3> $Gui = GUICreate("Scan/Pixs)", 72, 90, -1, -1, -1, BitOr($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) $icon = GUICtrlCreateIcon("shell32.dll", -202, 19, 19, 32, 32) GUICtrlSetState(-1, $GUI_DISABLE) $button = GUICtrlCreateButton("Scan", 10, 10, 52, 70, BitOr($WS_CLIPSIBLINGS, $BS_BOTTOM, $BS_MULTILINE)) GUICtrlSetFont(-1, 8, 700) GUISetState(@SW_SHOW, $Gui) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button ShellExecute("CSTBox.exe") EndSelect WEnd Edited December 27, 2007 by copyleft Link to comment Share on other sites More sharing options...
Madza91 Posted December 27, 2007 Share Posted December 27, 2007 This smashly's way is bugged :Show to make to be transparent a icon background? :s#include <GuiConstants.au3> $Gui = GUICreate("button icon", 200, 100, -1, -1) $ic = GUICtrlCreateIcon("shell32.dll", -30, 19, 19, 32, 32) GUICtrlSetState(-1, $GUI_DISABLE) $button = GUICtrlCreateButton("", 10, 10, 52, 70, $WS_CLIPSIBLINGS) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Link to comment Share on other sites More sharing options...
copyleft Posted December 29, 2007 Share Posted December 29, 2007 This smashly's way is bugged :S n3nE, Your window looks better but, again, how do you get two different buttons to execute seperate programs when clicked? Do I need an "else" statement? 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