Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB.NET
Expertise: Intermediate
Jan 20, 2004

Funk Up Your Forms with Fading

I find this particularly useful in an MDI environment where you don't want to keep switching forms to read information—just make the front form transparent to read the one behind, then fade it in again. Much nicer than Alt+Tab!! Can also be used when quitting programs for a bit of extra class (no pun intended...)

Create a form with two buttons—btnFadeIn & btnFadeOut and execute the appropriate function.

Drop in the following code:


---------------------------
Private Function FadeIn()
   ' attach to BtnFadeIn_Click
   Dim start, finish As Double
   Dim i As Integer
   i = 1
   start = Microsoft.VisualBasic.DateAndTime.Timer
   finish = start + 2.0

   Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
       If Me.Opacity < 1.0 Then
           Me.Opacity = ((i * 1) / 100)
           i = i + 1
       Else
           Exit Do
       End If
   Loop
End Function

Private Function FadeOut()
   ' attach to BtnFadeOut_Click - also Form1_Closing
   Dim start, finish As Double
   Dim i As Integer
   i = 1
   start = Microsoft.VisualBasic.DateAndTime.Timer
   finish = start + 1.0

   Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
       If Me.Opacity > 0.25 Then
           Me.Opacity = ((100 - (i * 1)) / 100)
           i = i + 1
       Else
           Exit Do
       End If
   Loop
End Function
DevX Staff
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap