Program a button press ?

Started by James Padgett, October 20, 2011, 11:06:43 PM

Previous topic - Next topic

James Padgett

How do you program a button push ?

I want to programatically determine when the Enter key is pressed in a text box and then activate the command button.
I have a 2nd form with 2 text boxes one a user name the other a password and want the ' OK ' ( command button ) pressed if the enter key is pressed from within the 2nd text box..

My thoughts are to get the text for each EN_CHANGE event and then if 'return' key detected send the event for pressing the command button..

Am I on the right track ?

Brian Chirgwin

On the button properties set the OK button to default.

Under Windows Style of the button set it to BS_DEFPUSHBUTTON
If your text box takes allows returns then the default button won't be clicked when pressing enter.

If you have a cancel button set the property Cancel to true. This is just below the Windows Style property.
By setting this property to true Esc key will be the same as clicking the cancel button.



James Padgett

That was easy ....  set it to BS_DEFPUSHBUTTON