litlmike Posted May 30, 2008 Share Posted May 30, 2008 I would like to have a button that when the user presses {ENTER} that the button will be pressed when the focus is not on the button. I thought $BS_DEFPUSHBUTTON would accomplish this, but it doesn't seem to work in the example below. Am I missing something, or is the only workaround to make this OnEvent mode? Thanks: From help file: Creates a push button with a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely option, or default. #include <ButtonConstants.au3> #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Select Appointment Date", 226, 101, 491, 383) $Date1 = GUICtrlCreateDate("2008/05/29 16:49:59", 20, 15, 186, 21) $ButtonOK = GUICtrlCreateButton("&Done", 75, 50, 75, 25, 0, $BS_DEFPUSHBUTTON ) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonOK Exit EndSwitch WEnd _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
ProgAndy Posted May 30, 2008 Share Posted May 30, 2008 It's a normal Style, no ExStyle $ButtonOK = GUICtrlCreateButton("&Done", 75, 50, 75, 25, $BS_DEFPUSHBUTTON ) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
sheck Posted May 30, 2008 Share Posted May 30, 2008 How about this: #include <ButtonConstants.au3> #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include<Misc.au3> $Form1 = GUICreate("Select Appointment Date", 226, 101, 491, 383) $Date1 = GUICtrlCreateDate("2008/05/29 16:49:59", 20, 15, 186, 21) $ButtonOK = GUICtrlCreateButton("&Done", 75, 50, 75, 25, 0, $BS_DEFPUSHBUTTON ) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonOK Exit EndSwitch If BitAND(WinGetState("Select Appointment Date"), 8) And _IsPressed("0D") Then Exit WEnd Live and Learn, 'cause Knowledge is Super Power. Link to comment Share on other sites More sharing options...
litlmike Posted May 30, 2008 Author Share Posted May 30, 2008 It's a normal Style, no ExStyle $ButtonOK = GUICtrlCreateButton("&Done", 75, 50, 75, 25, $BS_DEFPUSHBUTTON )Ahhh... thanks. _ArrayPermute()_ArrayUnique()Excel.au3 UDF 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