The information in this article applies to:
- Professional Edition of Microsoft Visual Basic for Windows,
versions 2.0 and 3.0
- Microsoft Professional Toolkit for Microsoft Visual Basic programming
system for Windows, version 1.0
SUMMARY
This article contains a program example of using the Visual Basic for
Windows Gauge custom control (GAUGE.VBX) with the HORZ1.BMP bitmap file.
MORE INFORMATION
NOTE: The GAUGE.VBX custom control file can be found in the
\Windows\System subdirectory. The HORZ1.BMP bitmap file can be found
in the \BITMAPS\GUAGE subdirectory that was created during installation.
Example Program
- Run Visual Basic for Windows, or from the File menu, choose New
Project (press ALT, F, N) if Visual Basic for Windows is already
running. Form1 is created by default.
- From the File menu, choose Add File. In the Files box, select the
GAUGE.VBX custom control file. The Gauge tool will appear in the
toolbox.
- Create the following controls for Form1:
Control Name Property Setting
-------------------------------------------------
Timer Timer1 Interval = 1
Gauge Gauge1 Picture = "Horz1.BMP"
Max = 50
InnerBottom = 16
InnerLeft = 38
InnerRight = 2
InnerTop = 14
ForeColor = &HFF&
(In Visual Basic version 1.0 for Windows, set the CtlName Property
for the above objects instead of the Name property.)
- Add the following line to the General Declarations section:
Dim YoYo As Integer
- Add the following code to the Form_Load event procedure:
Sub Form_Load ()
Form1.Caption = "YoYo Gauge Demo"
Gauge1.Value = Gauge1.Min
End Sub
- Add the following code to the Timer1_Timer event procedure:
Sub Timer1_Timer ()
If Gauge1.Value = Gauge1.Max Then YoYo = -1
If Gauge1.Value = Gauge1.Min Then YoYo = 1
Gauge1.Value = Gauge1.Value + YoYo
End Sub
When run, this program example will alternately fill and empty the
gauge control's fill area, as controlled by the Timer event procedure.
|