Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 12: Dialog-Based Windows


13.4 Control Design.............................................................................................


13.4.1..Controls Selection and Addition.......................................................


The controls used to provide functionality to your application are provided by an object
called the Controls toolbox. The Controls toolbox of both MSVC 6 and MSVC 7 gives
access to 25 controls:

Visual C++ 6 Controls Visual C++ 7 Controls

More objects, called ActiveX controls, can be accessed and added to the Controls toolbox
but such additional objects are made available only to the current application. To make
Windows controls available to your users, you will add them to their host object also
called a parent. To do this, you mostly click the desired control from the Controls toolbox
and click an 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 and release Ctrl. 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.

Another technique you can use to visually add a control is to “design” it. To do this, after
clicking the control from the Controls toolbox, you can click and hold the mouse on the
parent window, then drag left, up, right, or down. While you are dragging, you can refer
to the right section of the status bar for the current location and dimensions of the control:
Free download pdf