home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code2 / tag_it / fade.bas < prev    next >
BASIC Source File  |  1993-12-09  |  2KB  |  46 lines

  1. Option Explicit
  2.  
  3. '  Data type used by FillRect
  4. Type RECT
  5.     Left As Integer
  6.     Top As Integer
  7.     Right As Integer
  8.     Bottom As Integer
  9. End Type
  10.  
  11. '  API Functions used to create solid brush and draw brush on form
  12. Declare Function CreateSolidBrush Lib "GDI" (ByVal crColor As Long) As Integer
  13. Declare Function FillRect Lib "User" (ByVal hDC As Integer, lpRect As RECT, ByVal hBrush As Integer) As Integer
  14. Declare Function DeleteObject Lib "GDI" (ByVal hObject As Integer) As Integer
  15. Dim hBrush%
  16.  
  17. Sub FadeForm (TheForm As Form)
  18.     Dim FormHeight%, Blue%, StepInterval%, X%, RetVal%, OldMode%
  19.     Dim FillArea As RECT
  20.     OldMode = TheForm.ScaleMode
  21.     TheForm.ScaleMode = 3  'Pixel
  22.     FormHeight = TheForm.ScaleHeight
  23. ' Divide the form into 63 regions
  24.     StepInterval = FormHeight \ 63
  25.     Blue = 255
  26.     FillArea.Left = 0
  27.     FillArea.Right = TheForm.ScaleWidth
  28.     FillArea.Top = 0
  29.     FillArea.Bottom = StepInterval
  30.     For X = 1 To 63
  31.         hBrush% = CreateSolidBrush(RGB(0, 0, Blue))
  32.         RetVal% = FillRect(TheForm.hDC, FillArea, hBrush)
  33.         RetVal% = DeleteObject(hBrush)
  34.         Blue = Blue - 4
  35.         FillArea.Top = FillArea.Bottom
  36.         FillArea.Bottom = FillArea.Bottom + StepInterval
  37.     Next
  38. ' Fill the remainder of the form with black
  39.     FillArea.Bottom = FillArea.Bottom + 63
  40.     hBrush% = CreateSolidBrush(RGB(0, 0, 0))
  41.     RetVal% = FillRect(TheForm.hDC, FillArea, hBrush)
  42.     RetVal% = DeleteObject(hBrush)
  43.     TheForm.ScaleMode = OldMode
  44. End Sub
  45.  
  46.