Controls Designs on Forms and Dialog Boxes |
|
The controls used to provide functionality to a form or a dialog box are provided in a window called the Controls toolbox:
To make Windows controls available to your users, you will add them to their host object, which can be a dialog box or a form. To do this, you mostly click the desired control from the Controls toolbox and click the desired area on the host. You can keep adding controls on the dialog box as necessary. If you want to add a control over and over again, press and hold Ctrl. Then click the control on the Controls toolbox. Then click in the desired area on the host. Every time you click, the control would be added to the form or dialog box. Once you have added enough controls, click the control again on the Controls toolbox to deselect it. You can also press Esc. You cannot select more than one control to add on a host.
To visually manipulate a control, you will first need to select it. To select a control, simply click it. A control that is selected is surrounded with 8 (blue) handles. To select more than one control in the same area, click on the dialog box and draw a "fake" rectangle that encloses all of the needed controls. The first control from the selected group has 8 (blue) handles while the other control(s) from the same selected group has (have) 8 white handles (each). To select controls at random. Click one of them. Press and hold either Shift or Ctrl. Then click each one of the needed controls.
After you have added a control to a dialog box, it assumes either its default size or the size you drew it with. To help with the sizes of controls on the form or dialog box, Visual C++ provides a visual grid made of black points. To can display or hide the grid by clicking the Toggle Grid button . The dimensions of grid points are in dialog box units (DLUs) and are set at a default value of 5. To change this spacing, display the Guide Settings dialog box from the Layout menu and set the desired values. To change the size of a control, first select it. Then position the mouse on one of its handles. The mouse would assume a sizing cursor that indicates the possible type of resizing you can apply. The mouse cursors are:
To resize a control, that is, to give it a particular width or height, position the mouse on one of the handles and drag in the desired direction. If the Toggle Grid button is down, in which case the dialog or form would display the grid indicators, a control can be moved or resized only on the dotted lines. If you do not want to follow the grid indicators, you have two alternatives. You can hide the grid indicators by Toggle Guides button. On the other hand, you can press and hold Alt, then click the control or one its sizing handles and drag in the desired direction. To resize more than one control at the same time. Firs select them. Then use the following buttons from the Dialog toolbar: |
|
Practical Learning: Resizing Controls |
Controls Positions |
The controls you position on a dialog box or a form assume their given place. Most of the time, these positions are not practical. You can move them around to any positions of your choice.
To move a control, click and drag it, while the mouse cursor is a cross , in the desired direction until it reaches the intended position.
To move a group of controls, first select them. Then drag the selection to the desired location.
To help with positioning the controls, Visual C++ provides the Dialog toolbar with the following buttons:
|
Practical Learning: Moving Controls |
Tab Order |
The controls you add to a form or a dialog box are positioned in a sequence that follows the order they were added. When you add a control on the host that already has other controls, regardless of the section or area you place the new control, it is sequentially positioned at the end of the existing controls. If you do not fix it, the user would have a hard time navigating the controls.
The sequence of controls navigation is called the tab order. While designing a form or a dialog box, to change the sequential order of controls, on the main menu, click Layout or Format and click Tab Order or press Ctrl + D.
Practical Learning: Controlling Tab Order |
After this lesson, you should take an overview of MFC Controls
|
||
Previous | Copyright © 2003-2015, FunctionX | |
|