aaronl
asked on
Setting default button programmatically
During program execution, when a certain edit box gets the focus in a dialog, I want that to make a specific button become the default button, so that if the user presses ENTER while the edit box has focus, the button is pressed. I don't want this button to be the default button to start out with, just when this edit box is in focus. Then the default button can get changed back to the original one, or not - doesn't really matter.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks-
only thing to add is that you have to explicitly remove the previously marked default
button....
A
only thing to add is that you have to explicitly remove the previously marked default
button....
A
Oh, whoops :-) I didn't even know anything about this function until I looked searched for it the help. Anyway, I am glad you have it working.
ASKER
hey, all apologies for the "good" score as well... I didn't know the system, and someone told me that was worth an excellent.
Oh, that? It doesn't matter to me as long as you have a solution. I have enough points as it is :-)
CButton your_button; // Attach this to your button using classwizard
.
your_button.SetButtonStyle
---
First you want to attach a variable of type CButton to your button in the ClassWizard. Then, place the "SetButtonStyle" code at the point you want to change it to the default button. If you want to change the default button status back to another button, attach another variable of type CButton to the other button and do the same thing. If you have additional questions, please feel free to ask. Thanks!