Luigi Posted October 31, 2013 Share Posted October 31, 2013 (edited) I create a simple script, with two buttons. The first button make nothing. The second button only change the background color of first button. Every thing work nice... but... I need change button's color with $BS_LEFT or another style in the first button, this is the problem. Perhaps I use a wrong style in button. But when background color is changed, the style is missing. And try apply the style again, the background color is missing! 8D Try uncomment line 24 and comment it, to see. What is going on? I Try with $SS_LEFT and nothing is changing. #include-once #include <Misc.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> Global $hGui, $hMsg Global $color $hGui = GUICreate('title', 140, 80) $hButton0 = GUICtrlCreateButton('button', 10, 10, 120, 20, $BS_LEFT) GUICtrlSetBkColor($hButton0, 0xff0000) $hButton1 = GUICtrlCreateButton('change color', 10, 40, 120, 20) GUISetState(@SW_SHOWNORMAL) While 1 $hMsg = GUIGetMsg() Switch $hMsg Case $GUI_EVENT_CLOSE _exit() Case $hButton1 $color = _Iif($color == 0x00ff00, 0xff0000, 0x00ff00) GUICtrlSetBkColor($hButton0, $color) ;GUICtrlSetStyle($hButton0, $BS_LEFT);try coment and uncoment this line, and see the error... EndSwitch WEnd Func _exit() Exit EndFunc ;==>_exit Edited October 31, 2013 by detefon Visit my repository Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2013 Moderators Share Posted October 31, 2013 detefon,There is a bug deep within the core AutoIt GUI code (and which will not be fixed any time soon) which means that colouring buttons leads to all sorts of problems - they trap the {ENTER} key and refuse many style changes (as you have discovered). I suggest you drop the idea of coloured buttons and perhaps use a border - like this: #include <Misc.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> Global $hGui, $hMsg Global $color $hGui = GUICreate('title', 140, 80) $cLabel = GUICtrlCreateLabel("", 8, 8, 124, 24) GUICtrlSetBkColor($cLabel, 0xff0000) $hButton0 = GUICtrlCreateButton('button', 10, 10, 120, 20, $BS_LEFT) $hButton1 = GUICtrlCreateButton('change color', 10, 40, 120, 20) GUISetState(@SW_SHOWNORMAL) While 1 $hMsg = GUIGetMsg() Switch $hMsg Case $GUI_EVENT_CLOSE _exit() Case $hButton1 $color = _Iif($color == 0x00ff00, 0xff0000, 0x00ff00) GUICtrlSetBkColor($cLabel, $color) GUICtrlSetStyle($hButton0, $BS_LEFT);try coment and uncoment this line, and see the error... EndSwitch WEnd Func _exit() Exit EndFunc ;==>_exitHow does that look to you? M23 Luigi 1 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...
Luigi Posted October 31, 2013 Author Share Posted October 31, 2013 ohhhhh! This is not my mistake? I am happy! 8D And your reply solve another problem! With one answer, solve two questions! Thanks! Visit my repository Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2013 Moderators Share Posted October 31, 2013 detefon, With one answer, solve two questions!Wow, even better than normal! Glad I could help. What was the second problem? 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...
Luigi Posted October 31, 2013 Author Share Posted October 31, 2013 I want something to border/contourn a field data (input), like jquery ui or similar, but I dont have no idea to make this, and your reply, to put a label and button above is simple to simulate this effect! For me, solve the second question! 8D Visit my repository Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2013 Moderators Share Posted October 31, 2013 detefon,Excellent, but I forgot to mention that you need to disable the label if you want the control above it to be actionable. Try this script and you will see what I mean:#include <Misc.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <Constants.au3> Global $hGui, $hMsg Global $color $hGui = GUICreate('title', 140, 80) $cLabel = GUICtrlCreateLabel("", 8, 8, 124, 24) GUICtrlSetBkColor($cLabel, 0xff0000) ;GUICtrlSetState($cLabel, $GUI_DISABLE) ; Try with this commented and then not <<<<<<<<<<<<<<<<<<<<< $hButton0 = GUICtrlCreateButton('button', 10, 10, 120, 20, $BS_LEFT) $hButton1 = GUICtrlCreateButton('change color', 10, 40, 120, 20) GUISetState(@SW_SHOWNORMAL) While 1 $hMsg = GUIGetMsg() Switch $hMsg Case $GUI_EVENT_CLOSE _exit() Case $hButton1 $color = _Iif($color == 0x00ff00, 0xff0000, 0x00ff00) GUICtrlSetBkColor($cLabel, $color) Case $hButton0 MsgBox($MB_SYSTEMMODAL, "Hi", "Pressed") EndSwitch WEnd Func _exit() Exit EndFunc ;==>_exitSorry about that. 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...
Luigi Posted October 31, 2013 Author Share Posted October 31, 2013 Greate! The first step is ok! But... I don't have no idea for radio item (draw a circle around). GDIPlus? Is not a lot of power to a simple question? Perhaps GUICtrlSetGraphic to draw a circle under the radio? Its seems a choice... Is the good choice? I can't see nothing. Visit my repository Link to comment Share on other sites More sharing options...
BrewManNH Posted October 31, 2013 Share Posted October 31, 2013 Radio buttons can be colored, it's just normal buttons that can't. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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