slaughter Posted March 16, 2009 Share Posted March 16, 2009 Hi simple question how to use label as button. If I click label how to detect it ? didint found answe and on search In progress: Windows Server bruteforce GUARD Admin Tools (Remote client control) Bypasing firewall Old stuff: [font="Verdana;"]MD5 Auto Update Calendar XP SS multi usser server & client Autoit Remote Control (ARC)[/font] Link to comment Share on other sites More sharing options...
Developers Jos Posted March 16, 2009 Developers Share Posted March 16, 2009 (edited) add the correct style to the label control: $SS_NOTIFY Jos Edited March 16, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
slaughter Posted March 26, 2009 Author Share Posted March 26, 2009 add the correct style to the label control: $SS_NOTIFYJosmaybe small sample ? In progress: Windows Server bruteforce GUARD Admin Tools (Remote client control) Bypasing firewall Old stuff: [font="Verdana;"]MD5 Auto Update Calendar XP SS multi usser server & client Autoit Remote Control (ARC)[/font] Link to comment Share on other sites More sharing options...
BrettF Posted March 26, 2009 Share Posted March 26, 2009 Jos, isn't SS_NOTIFY a default for the control unless you've specified other styles, where you could use either SS_NOTIFY or GUI_SS_DEFAULT_LABEL? @Slaughter, just do the same as you do for buttons, handle the event in your message loop or using OnEvent... It really ain't that hard. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
BigDod Posted March 26, 2009 Share Posted March 26, 2009 I am in a good mood #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 633, 447, 193, 125) $Label1 = GUICtrlCreateLabel("Click Me", 208, 136, 97, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Label1 MsgBox(0,"", "You pushed the Button") EndSwitch WEnd Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Developers Jos Posted March 26, 2009 Developers Share Posted March 26, 2009 Jos, isn't SS_NOTIFY a default for the control unless you've specified other styles, where you could use either SS_NOTIFY or GUI_SS_DEFAULT_LABEL?I am sure JP must have changed that on me a while ago, but you are right. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BrettF Posted March 27, 2009 Share Posted March 27, 2009 Woo Thanks, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
JackDinn Posted March 27, 2009 Share Posted March 27, 2009 yea having the same problem, i wanted to add a background pic to a button , thought it would be easy just use GUICtrlSetImage but nooo dont work so i had a look around and it seems that most peeps are saying to use something else like a Label or a Pic and yea it does work but the control is nowhere near as responsive as a button, it misses presses and acts rather odd ? iv set up a demo of this , try clicking the Label several times it does not register all the clicks where as a button does. #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 633, 447, 193, 125) $but = GUICtrlCreateButton("Click Me", 208, 266, 197, 33) $Label1 = GUICtrlCreateLabel("Click Me", 208, 166, 197, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) $Ltimes = 0 $btimes = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Label1 GUICtrlSetData($Label1, "Click me .." & $Ltimes) $Ltimes += 1 Case $but GUICtrlSetData($but, "Click me .." & $btimes) $btimes += 1 EndSwitch WEnd so whats the answer to a background .jpg or .bmp to a button? i have posted asking this question already but noticed this thread after. cheers chaps. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 27, 2009 Moderators Share Posted March 27, 2009 JackDinn,Putting a .bmp on a button is easy. Create the button with the $BS_BITMAP style and use GUICtrlSetImage. Job done!However, if you want text on top of the bitmap life becomes a bit more complicated and I suggest you look at rover's script here.I am not sure that you can put a .jpg on a button. Using GUICtrlSetImage will not work - and this is unsurprising given that the available styles for buttons are for BITMAP and ICON and I know that .bmps and .jpgs are regarded as different resource types (BITMAP and RCDATA). Perhaps someone more experienced can us give chapter and verse later.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JackDinn Posted March 27, 2009 Share Posted March 27, 2009 (edited) yea me making assumptions again , thx for pointing that out .jpg is not a .bmp . However still wondering why even changing the colour of the text on a button makes it act in this strange way ? Edited March 27, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 27, 2009 Moderators Share Posted March 27, 2009 JackDinn, There are many threads about problems with buttons when they are coloured or have images. I know there is a longstanding bug in Trac concerning coloured buttons trapping the Enter key - and there was another thread a while back about slow response from buttons with coloured text. So I try to have my buttons just as they come - I do change the font sometimes, but I have not had any problems so far (touch wood!). M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JackDinn Posted March 27, 2009 Share Posted March 27, 2009 well thx for your responses , looks like im also guna be keeping my buttons just as god(JB) meant them to be, anything else looks like to much hassle for what it gains. have looked at some other UDF skins and buttons etc but its all a lot of grief so thx again in helping me make my finial decision in this case Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
rover Posted March 29, 2009 Share Posted March 29, 2009 JackDinn re, your post in the above thread mentioned by Melba23 you are limited to using the BMP format used by Microsoft with the behind the scenes API's used to make GuiCtrlSetImage() and set a common controls image unless you convert the jpg image to BMP buttons with images set that way don't have visual styles theme appearance (Windows classic only) because they are ownerdrawn (more code required to set images for all states) if you use an imagelist you get themed buttons and transparency and its not much extra code you can also make the button and image the same size and have a button that blends in with the background image of the gui and buttons response time is normal, no lag JPG or PNG on a themed button an example using available transparent PNG images on Windows XP works nicely with hi-res transparent PNGs Minimum Operating Systems: Windows XP. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <GuiImageList.au3> #Include <GDIPlus.au3> Opt("MustDeclareVars", 1) _Main() Func _Main() Local $sJPGImage1 = @WindowsDir & "\system32\DirectX\Dinput\SV-262e1.png" Local $sJPGImage2 = @WindowsDir & "\system32\DirectX\Dinput\gr4001_g.png" Local $btn1,$btn2,$msg, $iW1, $iH1, $iW2, $iH2 Local $hImagebtn1,$hImagebtn2,$hBitmap1,$hBitmap2,$hImage1,$hImage2 ;Caveat: Minimum Operating Systems: Windows XP. Local $hGUI = GUICreate("Button Imagelists - Minimum OS: Windows XP",520,600) ; Initialize GDI+ library _GDIPlus_Startup () ; convert jpg to bitmap $hImage1 = _GDIPlus_ImageLoadFromFile($sJPGImage1) $hImage2 = _GDIPlus_ImageLoadFromFile($sJPGImage2) $hBitmap1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage1) $hBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage2) ;Button 1 ;single state image Bitmap with overlayed text $btn1 = GUICtrlCreateButton("Test This", 10, 10, 500, 280) GUICtrlSetTip(-1, "Single bitmap imagelist") GUICtrlSetFont(-1, 16, 800, -1, "Comic Sans MS") ;Button imagelist ; get image W/H dimensions to set imagelist to size of image $iW1 = _GDIPlus_ImageGetWidth($hImage1) $iH1 = _GDIPlus_ImageGetHeight($hImage1) $hImagebtn1 = _GUIImageList_Create($iW1, $iH1, 5, 3) _GUIImageList_Add($hImagebtn1,$hBitmap1) _GUICtrlButton_SetImageList($btn1, $hImagebtn1, 0) ; last parameter sets centering of image on button ;Button 2 ;single state image Bitmap with overlayed text $btn2 = GUICtrlCreateButton("And This", 10, 310, 500, 280) GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text") GUICtrlSetFont(-1, 16, 800, -1, "Comic Sans MS") ;button imagelist ; get image W/H dimensions to set imagelist to size of image $iW2 = _GDIPlus_ImageGetWidth($hImage2) $iH2 = _GDIPlus_ImageGetHeight($hImage2) $hImagebtn2 = _GUIImageList_Create($iW2, $iH2, 5, 3) _GUIImageList_Add($hImagebtn2,$hBitmap2) _GUICtrlButton_SetImageList($btn2, $hImagebtn2, 0) ; last parameter sets centering of image on button ; Clean up resources after adding bitmaps to button imagelists _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _WinAPI_DeleteObject($hBitmap1) _WinAPI_DeleteObject($hBitmap2) ; Shut down GDI+ library _GDIPlus_ShutDown () GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $btn1 Beep(1000,5) Case $btn2 Beep(1000,5) EndSwitch WEnd EndFunc ;==>_Main I see fascists... Link to comment Share on other sites More sharing options...
JackDinn Posted March 29, 2009 Share Posted March 29, 2009 nice reply, thx, oddly enough i was just looking into ImageLists (just to learn, i'll prob just use normal buttons for now) but your example script will help out. thx. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D 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