Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
George Omura. Lisp programing tutorial for AutoCAD customization / Using VBA to Create AutoCAD Applications - Omura, George.pdf
Скачиваний:
120
Добавлен:
02.05.2014
Размер:
883.43 Кб
Скачать

TYPES OF CONTROLS

13

Figure 99.10 The OptionButton control

The ToggleButton Control

ToggleButton controls provide yet another interface for choosing between a pair of states. When its value is True, a toggle button is drawn depressed (see the top toggle button in Figure 99.11). When the value is False, the toggle button is drawn normally (see the bottom toggle button in Figure 99.11).

You won’t find too many toggle buttons in the Windows interface these days; they seem to be obsolete. But you should consider them if you have a small number of exclusive options to choose from.

Be sure you don’t choose the ToggleButton control when you mean to use the CommandButton control!

Figure 99.11 The ToggleButton control

Copyright ©2001 SYBEX, Inc., Alameda, CA

www.sybex.com

14

CHAPTER NINETY-NINE • USING VBA TO CREATE AUTOCAD APPLICATIONS

The Frame Control

A Frame control can be used to group other controls (check boxes, option buttons, or toggle buttons) together. This is both a visual and a logical grouping. For example, if you have two frames with option buttons on a form, then one option button in each frame can be selected, rather than one option button on the entire form. Figure 99.12 shows a set of frames that contain controls.

To create a frame that contains controls, first create the frame and make sure it is selected. Then choose the tool for the control you want to place inside of the frame, and drop it on top of the frame. You can also select a control that’s already on a UserForm, cut it from the UserForm, select the frame, and paste it into the frame.

Frames add a nice visual touch to any form, and allow the user to easily see how a complex set of options is grouped. Most printer setup dialog boxes in Windows, for example, make use of frames for this purpose.

Figure 99.12 The Frame control

The CommandButton Control

Command buttons (Figure 99.13) provide the easiest way for a user to interact with your application. Command buttons are ubiquitous in Windows: they’re the regular buttons you can click with the mouse or keyboard to make things happen. Later in this chapter you’ll see how events make it possible for you to sense when the user presses a command button and cause code to run in response to this action (or many others).

Copyright ©2001 SYBEX, Inc., Alameda, CA

www.sybex.com

TYPES OF CONTROLS

15

Command buttons are appropriate any time you need to allow the user to start some sequence of actions when they’re ready, as opposed to when the application is first loaded.

Figure 99.13 The CommandButton control

The TabStrip Control

The TabStrip control provides one implementation of the visual “tabbed page” metaphor for grouping information. This metaphor is used extensively in Windows 95. For example, almost every property page uses multiple tabs to group information together in a limited space. Figure 99.14 shows a TabStrip control with two tabs.

If you use a TabStrip control to group information, you’ll need to write code to display the proper information as the user selects each tab. Unless you have a very limited amount of information to show, this can become a daunting task.

For most grouping purposes, you’ll find the MultiPage control easier to use than the TabStrip control.

Copyright ©2001 SYBEX, Inc., Alameda, CA

www.sybex.com

16

CHAPTER NINETY-NINE • USING VBA TO CREATE AUTOCAD APPLICATIONS

Figure 99.14 The TabStrip control

The MultiPage Control

Like the TabStrip control, the MultiPage control (shown in Figure 99.15) allows you to create separate visual regions for separate pieces of information. However, the implementation of the MultiPage is normally easier to work with. This control, as its name implies, provides you with multiple “pages,” each of which can contain other controls. The MultiPage control manages the details of hiding and showing these contained controls when the user selects a tab, so you don’t have to write code for this task.

The Value property of the MultiPage control will tell you which page is topmost at any given time. You can also set the Value property to display a specific page.

MultiPage controls are appropriate any time you need to display many controls in a limited space. If you’re writing a complex AutoCAD application, consider using a MultiPage control to minimize the size of the dialog box, which in turn will minimize the amount of the drawing that your application obscures.

Copyright ©2001 SYBEX, Inc., Alameda, CA

www.sybex.com