Re: Fade image in and out
There is no such thing as control transparencies, not really. Fading can be done using a backbuffer to hold the original image (whether its an memory bitmap or hidden picturebox with AutoRedraw=True). Either way, you'd want to use AlphaBlend API. You're not going to be able to fade an image control
The idea is via use of a timer or a DoEvents loop
1) Clear area to be drawn
2) Use AlphaBlend to render image at a reduced opacity
3) Pause & repeat as needed
Try searching forum for: fade picture
Re: Fade image in and out
Quote:
Originally Posted by
LaVolpe
There is no such thing as control transparencies, not really. Fading can be done using a backbuffer to hold the original image (whether its an memory bitmap or hidden picturebox with AutoRedraw=True). Either way, you'd want to use AlphaBlend API. You're not going to be able to fade an image control
The idea is via use of a timer or a DoEvents loop
1) Clear area to be drawn
2) Use AlphaBlend to render image at a reduced opacity
3) Pause & repeat as needed
Try searching forum for: fade picture
Thanks, Fox. I would have liked to have done this about 5 to 10 years ago. I love fade-in and fade-out for images and so did my sponsors. I had no idea that it was available back then. Dang it. I missed the boat. :sick:
Re: Fade image in and out
Canadian Weather Man, if you'd like to play with my Alpha Image Control. It can do what you are asking, but the control may be overkill for what you need. See it linked in my signature below. To fade, sample code might look like:
Code:
Private Sub Command1_Click()
Timer1.Tag = "FadeOut"
Timer1.Interval = 60 ' ??
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If Timer1.Tag = "FadeOut" Then
AlphaImgCtl1.TransparencyPct = AlphaImgCtl1.TransparencyPct + 10 ' step at 10%
If AlphaImgCtl1.TransparencyPct = 100 Then Timer1.Tag = "Pause"
ElseIf Timer1.Tag = "Pause" Then
Timer1.Tag = "FadeIn" ' fade back in now
Else
AlphaImgCtl1.TransparencyPct = AlphaImgCtl1.TransparencyPct - 10 ' step back 10%
If AlphaImgCtl1.TransparencyPct = 0 Then Timer1.Enabled = False ' done; stop timer
End If
End Sub
Edited: Modified sample routine for a complete fade out then fade in