VB and VBA Users Source Code: Fade a picturebox into a container
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Fade a picturebox into a container
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Monday, July 29, 2002
Hits:
953
Category:
Windows Forms/GUI/Controls/Graphics
Article:
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 'Author : Andrew Baker (copyright www.vbusers.com) 'Date : 25/03/2001 '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
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder