|
To access the contents, click the chapter and section titles.
Advanced Visual Basic Techniques
(Publisher: John Wiley & Sons, Inc.)
Author(s): Rod Stephens
ISBN: 0471188816
Publication Date: 06/01/97
Chapter 16 Histogram
ActiveX controls can be used in almost the same ways as any other control. In particular, an ActiveX control can be used to create other ActiveX controls.
This chapter describes a histogram control built using the gauge control described in Chapter 15. The first section in the chapter, Using Histogram, describes how the control works from the end users point of view. It explains the controls run-time behavior and the means by which the user can interact with the control.
The next section, Programming with Histogram, describes the controls features from an application designers point of view. It explains the properties and events a client application can use to manage the control.
The Key Techniques section briefly outlines the main tasks the control performs to support both the application developer at design time and the end user at run time. The rest of the chapter describes the histogram controls internals and explains how the control handles these key tasks.
Using Histogram
The histogram control displays a series of data values using gauge controls. A scroll bar allows the user to move through the values if there are more data values than gauges. If the controls Enabled property is set to true, the user can also modify the data using the gauges.
The project group HistTest.GRP in the Ch16 directory includes the test program project HistTest.VPJ. This program displays a single form containing a histogram control. Figure 16.1 shows the HistTest program displaying test data.
Programming Histogram
The histogram control is designed primarily for use with gauge controls of the tic gauge style. For that reason, histogram supports the TicWidth property used by tic gauge controls. This property and several others are delegated to the gauge controls contained in the histogram. Table 16.1 lists properties delegated to the gauges. Table 16.2 lists the other properties supported by the histogram control.
FIGURE 16.1 Test program HistTest.
The histogram controls NumBars property indicates the number of bar gauges the control should display. The control automatically calculates the width it needs to display that number of gauges with a reasonable separation between them.
| Table 16.1 Histogram Properties Delegated to the Gauge Controls
|
| Property
| Type
| Meaning
|
| BarBackColor
| OLE_COLOR
| Background color for gauges
|
| BarForeColor
| OLE_COLOR
| Foreground color for gauges
|
| Enabled
| Boolean
| Allows the user to change gauge values
|
| Max
| Long
| Maximum value displayed by gauges
|
| Min
| Long
| Minimum value displayed by gauges
|
| Style
| HistStyle
| The gauge style. May be one of: styleBar styleDial stylePic styleTic styleWid
|
| TicWidth
| Long
| Width of gauge tic marks
|
|
| Table 16.2 Histogram Properties That Are Not Delegated
|
| Property
| Type
| Meaning
|
| BackColor
| OLE_COLOR
| Background color of the histogram control
|
| NumBars
| Integer
| Number of gauges
|
| NumValues
| Integer
| Number of data values
|
| Value
| Long
| A single data value
|
|
|