![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Advanced Visual Basic Techniques
Table 17.1 lists the decimal values of some useful colors. These colors are standard system colors so they should be available on most computers. The Web page Colors.HTM in the Ch17 subdirectory displays the colors listed in Table 17.1. It creates a table that displays a sample of each of the colors, together with its name and decimal value. The page uses the BackColor properties of WebLabel controls to display the color samples. As with other Web pages, you will need to change the class ID and CODEBASE values used by this page before you can display it on your system.
The following code shows the table row entry Colors.HTM used to display the color sky blue. The <TR> and </TR> tags delimit a table row. Within a row the <TD> and </TD> tags delimit the table data entries. Each of the entries is placed in a separate column in the row.
<TR>
<TD>
<OBJECT WIDTH=50 HEIGHT=20
CLASSID=CLSID:1AC27CA9-9A55-11D0-AA35-0000E8167669
CODEBASE=http://beauty/WebLabel/WebLabel.CAB#version=1,0,0,0>
<PARAM NAME=BackColor VALUE=15780518>
</OBJECT>
</TD>
<TD>Sky blue</TD>
<TD>15780518</TD>
</TR>
The HTML code in PickClr.HTM in the Ch17 subdirectory is also useful for selecting colors. It creates a bar gauge control and a label control for each of the colors red, green, and blue. It then creates two labels named ColorSwatch and ColorLabel. Using the bar gauges, the user can adjust the amount of red, green, and blue that should be combined to form a new color. When the user changes a gauges value, a VBScript event handler updates the gauges corresponding label to show the amount of the color selected on a 0 to 255 scale. It then calculates the new color value using the specified amounts of red, green, and blue. It sets the BackColor property of the ColorSwatch label to this value so the user can see a sample of the color. It also updates the ColorLabel controls Caption property so the user can see the colors decimal value. The following code shows the portions of PickClr.HTM that deal with the red color component. The code that handles the green and blue colors is very similar.
<HTML>
:
<!-- Red gauge -->
<OBJECT ID=RedGauge WIDTH=200 HEIGHT=18
CLASSID=CLSID:1AC27B55-9A55-11D0-AA35-0000E8167669
CODEBASE=http://beauty/Gauge/Gauge.CAB#version=1,0,0,0>
<PARAM NAME=ForeColor VALUE=255>
<PARAM NAME=BackColor VALUE=12632256>
<PARAM NAME=Min VALUE=0>
<PARAM NAME=Max VALUE=255>
<PARAM NAME=Value VALUE=128>
<PARAM NAME=Style VALUE=0>
</OBJECT>
<!-- Red gauges label -->
<OBJECT ID=RedLabel WIDTH=50 HEIGHT=18
CLASSID=CLSID:1AC27CA9-9A55-11D0-AA35-0000E8167669
CODEBASE=http://beauty/WebLabel/WebLabel.CAB#version=1,0,0,0>
<PARAM NAME=ForeColor VALUE=0>
</OBJECT>
<BR>
:
<!-- Create gauges and labels for green and blue similarly -->
:
<!-- Labels to display the selected color -->
<OBJECT ID=ColorSwatch WIDTH=50 HEIGHT=50
CLASSID=CLSID:1AC27CA9-9A55-11D0-AA35-0000E8167669
CODEBASE=http://beauty/WebLabel/WebLabel.CAB#version=1,0,0,0>
</OBJECT>
<OBJECT ID=ColorLabel WIDTH=50 HEIGHT=18
CLASSID=CLSID:1AC27CA9-9A55-11D0-AA35-0000E8167669
CODEBASE=http://beauty/WebLabel/WebLabel.CAB#version=1,0,0,0>
</OBJECT>
<BR>
<SCRIPT LANGUAGE=VBScript>
<!--
Red events
Sub RedGauge_Scroll
RedLabel.Caption = RedGauge.Value
ShowColor
End Sub
Sub RedGauge_Change
RedLabel.Caption = RedGauge.Value
ShowColor
End Sub
The green and blue events are similar.
:
Set the initial label values when we load.
Sub Window_OnLoad
RedGauge_Change
GreenGauge_Change
BlueGauge_Change
End Sub
Update the color swatch and label
Sub ShowColor
Dim val
val = ((BlueGauge.Value * 256) + _
GreenGauge.Value) * 256 + RedGauge.Value
ColorLabel.Caption = val
ColorSwatch.BackColor = val
End Sub
-->
</SCRIPT>
</BODY>
</HTML>
Once again, you need to modify the code to set the correct class IDs and CODEBASE values before you can run this page on your computer.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
|