
alpha-blend / fade-in controls?
Quote:
> look the AnimateWindow() at MSDN
That will only work on Win2K, the alpha transparency isn't supported in
Win9x or WinME.
As an alternative solution, try this:
Add two picture box's to a form, put your start image in picture 1, and your
end image in picture 2 (Preferably the same size). Then paste this code in
and run:
'*** START CUT ***'
Private Declare Function GetPixel Lib "gdi32" _
(ByVal hDC As Long, ByVal X As Long, _
ByVal Y As Long) As Long
Private Declare Function SetPixelV Lib "gdi32" _
(ByVal hDC As Long, ByVal X As Long, _
ByVal Y As Long, ByVal crColor As Long) As Long
Dim Fading As Boolean
Const NumFrames = 10 'Number of fade frames
Private Sub Form_Load()
With Form1
.AutoRedraw = True
.ScaleMode = vbPixels
End With
With Picture1
.AutoRedraw = True
.ScaleMode = vbPixels
.Visible = False
.AutoSize = True
End With
With Picture2
.AutoRedraw = True
.ScaleMode = vbPixels
.Visible = False
.AutoSize = True
End With
End Sub
Private Sub Form_Click()
Dim PicWid As Integer, PicHgt As Integer
Dim SrcPic() As Pixel
Dim DestPic() As Pixel
Dim DrawX As Integer, DrawY As Integer
Dim FadeLoop As Single
Dim FadeStep As Single
If Fading Then Exit Sub
Fading = True
Form1.Picture = Picture1.Picture
Form1.Caption = "Scanning..."
DoEvents
With Picture1
PicWid = .ScaleWidth - 1
PicHgt = .ScaleHeight - 1
'Allocate some memory to store the images
ReDim SrcPic(PicWid, PicHgt) As Pixel
ReDim DestPic(PicWid, PicHgt) As Pixel
'Scan the images into memory
For ScanX = 0 To PicWid
For ScanY = 0 To PicHgt
SrcPic(ScanX, ScanY) = LongToPix( _
GetPixel(.hDC, ScanX, ScanY))
DestPic(ScanX, ScanY) = LongToPix( _
GetPixel(Picture2.hDC, ScanX, ScanY))
Next ScanY
Next ScanX
Form1.Caption = "Fading (0%)"
FadeStep = 255 / NumFrames
'Main fade loop
For FadeLoop = 0 To 255 Step FadeStep
For DrawX = 0 To PicWid
For DrawY = 0 To PicHgt
SetPixelV Form1.hDC, DrawX, DrawY, _
PixToLong(TransPix(SrcPic(DrawX, DrawY), _
DestPic(DrawX, DrawY), FadeLoop / 255))
Next DrawY
Next DrawX
Form1.Caption = "Fading (" & _
Int(((FadeLoop + FadeStep) / 255) * 100) & "%)"
Form1.Refresh
Next FadeLoop
End With
'Show the final image, then swap the original two
' (So it fades back next time)
Form1.Picture = Picture2.Picture
Picture2.Picture = Picture1.Picture
Picture1.Picture = Form1.Picture
Form1.Caption = "Done!"
Fading = False
End Sub
'*** END CUT **'
Click the form to show the animation, it's a lot faster when compiled, but
still reasonably slow unfortunately. For more speed interlace the
transparency frames, or convert it to DIB's (Or both!)
Hope this helps,
Mike
-- EDais --
WWW: Http://Members.xoom.com/EDais/