VS2010/MFC Setting the tab Order of a dialog box control

Source: Internet
Author: User

To set the tab order of a dialog box control

The previous sections show you the complete authoring process for the addition Calculator program, which focuses on how the tab order of the Controls on the dialog box is adjusted .

The addition calculator has been able to add operations to floating-point numbers after adding a message handler function for the Calculate button. But there is a small problem left, that is, the dialog Box control tab order problem.

Run the addition Calculator program, display the dialog box without any action, press ENTER directly, you can see the dialog box exited. This is because the Exit button is a control that has a tab order of 1, which is the first control that accepts user input. But according to our input habits, should be addend edit box first accept the user input, then the Addend edit box, and then the "Calculate" button, and finally the "exit" button.

Let's take a visual look at the tab order of each control. Open Resource View, and then locate the dialog box in the resource Idd_addition_dialog, double-click the ID and the intermediate customer area appears with its template view. in the main menu, choose Format, tab order, or press the shortcut key to Ctrl+d, and the dialog box template displays the tab number of each control. such as:

has a number in the upper-left corner of each control, which is its tab response order. When the dialog box just opens, the input focus is on the Exit button with tab order 1, the TAB key is pressed without any action, and the input focus is transferred to the "Summand" Static text box with Tab order 2, but because the static text box does not accept any input, So the input focus continues to be automatically transferred to the tab order 3 Summand edit box, and then the TAB key, the input focus will be transferred to the tab order 4 of the "Addend" Static text box, also because it is a static text box, the input focus does not stop to continue to transfer to the Addend edit box, the same as the following controls.

We think that this order is unreasonable, how to change it? It's easy to start by clicking on the control that you think the tab order should be 1 , and as you click Done, the tab response order for each control is set as we thought.

For example, in this example we can click the Summand edit box, the Summand static text box, the Addend edit box, the Addend static text box, and the edit box, the and static text box, the calculation button, and the Exit button. After the setup is complete, such as:

Finally press the ESC key to confirm the setting and exit the dialog template's tab order setting state.

Now we run the program, we can see the dialog box opened after the initial input focus on the Addend edit box, and we press the TAB key, the input focus moves to the Addend edit box, continue to press the TAB key more than once, the input focus will press the "and edit box-" calculation "button--' Exit ' button--summand edit box--addend edit box--and edit box ... "in the order of the loop transfer. That's what we're going to achieve.

VS2010/MFC Setting the tab Order of a dialog box control

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.