Visual Basic Tip: 03/25/96


Smooth blue shaded background.

How to get a smooth blue shaded background on a form (such as for a setup
program).  The earlier VB tip (10/23/95) on form shading doesn't produce a
smooth shade of blue.  This new method gives a smooth shade of blue.

1. Create a 1x1 pixel .BMP with all the shades of blue in its palette.   
   I used Paint Shop Pro to grab an area of Set program's smooth blue
   shaded Setup screen.  Run a setup program that has a smooth blue 
   shading.  Have something like Paint Shop Pro (PSP) running.  Alt-Tab 
   to switch to PSP.  Screen capture the smooth blue screen area. 
   Crop the image to a 1x1 pixel bitmap.  Save as a bitmap (ex: blue.bmp).

2. Set the picture property of the form to the .BMP (ex: blue.bmp) you have
   just created.  The .BMP is around 1082 bytes in size so this won't slow 
   anything down).  This alters the palette of the form to contain the shades
   of blue.

3. Use the code below:

Sub Form_Paint ()
  Form_Paintblue
  Form_Print 16, 16, "Here is some text"
End Sub


Sub Form_Paintblue ()
  Dim i As Integer
  Dim blueheight As Integer
  Me.ScaleMode = 3   'pixel
  blueheight = Me.ScaleHeight \ 256
  For i = 0 To 255
    Me.Line (0, i * blueheight)-Step(Me.ScaleWidth, blueheight), RGB(0, 0, 255 - i), BF
  Next
End Sub


Sub Form_Print (ByVal x As Single, ByVal y As Single, ByVal text As String)
   Me.FontName = "Arial"
   Me.FontBold = True
   Me.FontSize = 24
   Me.CurrentX = x + 2
   Me.CurrentY = y + 2
   Me.ForeColor = &H0&  'black
   Me.Print text
   Me.CurrentX = x
   Me.CurrentY = y
   Me.ForeColor = &HFFFFF
   Me.Print text
End Sub


Return to Phil's Web Page

Created by: Philip