Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows
Visual Basic > Forms sample source codes
Creating a faded background on a form
Creating a faded background on a form The code below fades (washes) the background of a form with a specified color range. 'Purpose : Fades the backcolor of a form (useful for installation screens/wizards etc). 'Inputs : oForm The form to fade the backcolor on. ' [lBaseColor] The base color to use in the form fade. ' [lFadeColor] The color to fade the base color to. 'Outputs : N/A 'Example : FormFadeBackColor Me, vbBlue, vbGreen ' FormFadeBackColor Me, vbRed, vbGreen Sub FormFadeBackColor(oForm As Form, Optional lStartColor As Long = vbBlack, Optional lEndColor As Long = vbBlue) Dim lRedStart As Long, lGreenStart As Long, lBlueStart As Long Dim lRedEnd As Long, lGreenEnd As Long, lBlueEnd As Long Dim fRedStep As Double, fGreenStep As Double, fBlueStep As Double Dim lStep As Long On Error GoTo ErrFailed oForm.AutoRedraw = True oForm.DrawStyle = vbInsideSolid oForm.DrawMode = vbCopyPen oForm.DrawWidth = 2 oForm.ScaleMode = vbPixels lRedStart = lStartColor And vbRed lGreenStart = (lStartColor And vbGreen) / (vbRed + 1) lBlueStart = (lStartColor And vbBlue) / (vbGreen + 1) lRedEnd = lEndColor And vbRed lGreenEnd = (lEndColor And vbGreen) / (vbRed + 1) lBlueEnd = (lEndColor And vbBlue) / (vbGreen + 1) fRedStep = (lRedEnd - lRedStart) / oForm.ScaleHeight fGreenStep = (lGreenEnd - lGreenStart) / oForm.ScaleHeight fBlueStep = (lBlueEnd - lBlueStart) / oForm.ScaleHeight For lStep = 0 To oForm.ScaleHeight oForm.Line (oForm.ScaleLeft, oForm.ScaleTop + lStep)-(oForm.ScaleLeft + oForm.ScaleWidth, oForm.ScaleTop + lStep), RGB(lRedStart + lStep * fRedStep, lGreenStart + lStep * fGreenStep, lBlueStart + lStep * fBlueStep), BF Next Exit Sub ErrFailed: Debug.Print err.description Debug.Assert False End Sub
Privacy Policy
|
Link to Us
|
Links