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 > Other sample source codes
Fade a picturebox into a container
Fade a picturebox into a container The following code demonstrates how to fade a picture, contained in a picture box, into another object (eg. a form): 'Purpose : Fade a picture contained in a picture box into a container (eg. a form) 'Inputs : oDestination The destination object to fade the picture into. ' picSource The picture box containing the picture ' [fStepRate] The rate a which to fade the picture into the container. 'Outputs : N/A 'Notes : Must place code in Form_Paint event ' eg. at the top of a form place the following code 'Private Sub Form_Paint() ' Static sbFaded As Boolean ' If sbFaded = False Then ' 'Fade the picture ' sbFaded = True ' Picture1.AutoSize = True ' PictureFade Me, Picture1 ' Else ' 'Refresh the picture ' With Me ' .PaintPicture Picture1.Picture, 0, 0, .ScaleWidth, .ScaleHeight, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbSrcCopy ' End With ' End If 'End Sub Sub PictureFade(oDestination As Object, picSource As PictureBox, Optional fStepRate As Single = 0.55) Dim fCount As Single oDestination.ScaleMode = vbPixels picSource.ScaleMode = vbPixels With oDestination For fCount = 1 To picSource.ScaleWidth Step fStepRate .PaintPicture picSource.Picture, 0, 0, .ScaleWidth, .ScaleHeight, 0, 0, fCount, picSource.ScaleHeight, vbSrcCopy 'Allow the user to interact with the screen DoEvents Next End With End Sub
Privacy Policy
|
Link to Us
|
Links