Dana Posted January 5, 2010 Share Posted January 5, 2010 (edited) I'm having trouble with the $BS_DEFPUSHBUTTON style; I can't seem to get it to work. I assign the style when creating the buttons: $printbutton = GUICtrlCreateButton("&Print", 30, $h - 40, 60) $closebutton = GUICtrlCreateButton("&Close", $w - 30 - 60, $h - 40, 60) $setupbutton = GUICtrlCreateButton("&Setup", 120, $h - 40, 60) $editbutton = GUICtrlCreateButton("&Edit", 210, $h - 40, 60) $addbutton = GUICtrlCreateButton("&Add", 300, $h - 40, 60, -1, -1, $BS_DEFPUSHBUTTON) $cancelbutton = GUICtrlCreateButton("Cance&l", 390, $h - 40, 60, -1) ; used in data entry mode $savebutton = GUICtrlCreateButton("&Save", 300, $h - 40, 60, -1) ; used in data entry mode GUICtrlSetState($cancelbutton, $GUI_HIDE) GUICtrlSetState($savebutton, $GUI_HIDE) Next, a listview is created and the GUI shown. When the GUI is displayed, I have the heavy border around the Add button, but hitting enter doesn't activate it. I can, however, click on it or ALT-A to activate it. This button runs a user function which first creates some input boxes, gives one the focus, and then this code among other things: GUICtrlSetState($addbutton, $GUI_HIDE) guictrlsetstyle($addbutton, -1) GUICtrlSetState($printbutton, $GUI_HIDE) GUICtrlSetState($editbutton, $GUI_HIDE) GUICtrlSetState($setupbutton, $GUI_HIDE) GUICtrlSetState($cancelbutton, $GUI_SHOW) GUICtrlSetState($savebutton, $GUI_SHOW) GUICtrlSetStyle($savebutton, $BS_DEFPUSHBUTTON) As I understand it, this should clear the $BS_DEFPUSHBUTTON style from the Add button which is hidden anyway, and apply the style to the Save button. However, in this case, I don't see the heavy border on the Save button nor does it accept the enter. What I'm trying to do is hit enter to enter a data entry mode, enter the data in the input boxes, tabbing between them, then hit enter to save the data and return to the main screen (another function shows the hidden buttons and hides the save and cancel buttons again), where enter lets me enter another set of data. But I can't get it to work without mouse clicks or ALT-key combinations. Yes, I have included all the appropriate constants files. What am I doing wrong? Edited January 5, 2010 by Dana Link to comment Share on other sites More sharing options...
GEOSoft Posted January 5, 2010 Share Posted January 5, 2010 Here is a tip for you. Instead of creating 2 buttons then hiding/showing them and having to mess with styles, use one button and GUICtrlSetData() to change the text. Then you can conditionally call the functions you want either based on GUICtrlRead() or a variable that is set each time the button is clicked. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Dana Posted January 5, 2010 Author Share Posted January 5, 2010 Here is a tip for you.Instead of creating 2 buttons then hiding/showing them and having to mess with styles, use one button and GUICtrlSetData() to change the text. Then you can conditionally call the functions you want either based on GUICtrlRead() or a variable that is set each time the button is clicked.Thanks, that might be a good idea. Still doesn't address why $BS_DEFPUSHBUTTON isn't working, though. Link to comment Share on other sites More sharing options...
picaxe Posted January 5, 2010 Share Posted January 5, 2010 Thanks, that might be a good idea. Still doesn't address why $BS_DEFPUSHBUTTON isn't working, though. Most likely because this line $addbutton = GUICtrlCreateButton("&Add", 300, $h - 40, 60, -1, -1, $BS_DEFPUSHBUTTON)should be$addbutton = GUICtrlCreateButton("&Add", 300, $h - 40, 60, -1, $BS_DEFPUSHBUTTON) Link to comment Share on other sites More sharing options...
Dana Posted January 5, 2010 Author Share Posted January 5, 2010 (edited) Most likely because this line $addbutton = GUICtrlCreateButton("&Add", 300, $h - 40, 60, -1, -1, $BS_DEFPUSHBUTTON)should be$addbutton = GUICtrlCreateButton("&Add", 300, $h - 40, 60, -1, $BS_DEFPUSHBUTTON) Doh! That solved half the problem. I still can't get GUICtrlSetStyle to work with $BS_DEFPUSHBUTTON, though. No matter though; I took GEOSoft's advice and used a single default button, changing the text and event it was set to as appropriate. Now it all works as it should. Thanks all. Edited January 5, 2010 by Dana 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