I had a client recently who was using two SQL Server dialogs in their installation, and they wanted to advance to the next dialog when the user hit the Return key in the fields. The two dialogs we are talking about are SQLServerSelect and SQLServerLogin. Well, I thought this would be a piece of cake and I was wrong.
I tried everything to do this. When the user was in the Edit field of the SQLServerLogin dialog, I would get the handle to the control and then set the focus to it in the proper case statement. That didn’t work.
I also set the ES_WANTRETURN style in the Other Windows Styles for the Edit control in the SQLServerLogin dialog. That would surely work. Well, it didn’t. Here is the dialog I am referring to:
Other Window Styles Dialog Box for an Edit Control
The answer was to set the tab order. For the SQLServerLogin dialog, I set the Login ID Edit control Tab Stop to 1, the Password Tab Stop to 2 and the Next button to 3. Like this:
SQLServerLogin Dialog Box
For the SQLServerSelect dialog, I set the Database Server ComboBox control Tab Stop to 1 and the Next button to 2:
SQLServerSelect Dialog Box
Remember this the next time you have to do something like this. It will save you some time.