-
Dec 16th, 2003, 08:03 PM
#1
Thread Starter
Frenzied Member
vb.net--fading a form out or in
to make you form fade when it loses focus or vice-versa, try this out:
Code:
Private Sub fclsCallsLogger_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Deactivate
'this routine fades the form when it loses focus
Dim x As Decimal = 0
Do While Me.Opacity > 0.5
Me.Refresh()
Me.Opacity -= 0.05
For x = 1 To 100000
Next x
Loop
End Sub
just change the control (fclscallslogger) to your form's name and viola'! to fade it, reverse the '>' and me.opacity -
to make it 100% opace,:
Code:
Private Sub fclsCallsLogger_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
'when the form receives focus again, we must make opacity 100%
Me.Opacity = 1
End Sub
Enjoy!
-
Oct 11th, 2005, 01:39 AM
#2
Addicted Member
Re: vb.net--fading a form out or in
I Wanted to Ask, If the Form is is Minimized, then fclsCallsLogger_Deactivate is Excuted or do you have to use fclsCallsLogger_MinimumSizeChanged
Curiosity SKILLED the cat
Google Talk from your Mobile phone
Chat from your mobile or get an emulator like J2ME Wireless Toolkit 2.2
-
Apr 16th, 2007, 07:44 AM
#3
Junior Member
Re: vb.net--fading a form out or in
There is a problem with that code, though. If the form gains focus again while it is fading, the whole application just jams...
There is a simpler method, which also avoids that error.
Create a timer. Lets call the timer "Timer_fade"
Create a button for Exit, call it "btnExit"
Add this:
Code:
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Timer_fade.Enabled = True
End Sub
Private Sub Timer_fade_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer_fade.Tick
If Me.Opacity > 0.1 Then
Me.Opacity -= 0.015
Else
Me.Close()
Timer_fade.Enabled = False
End If
End Sub
Do note that that is the Fade OUT code. I'm sure you know how to do fade in with that given. If there are any questions, just reply here.
-
Apr 12th, 2011, 07:47 AM
#4
New Member
Re: vb.net--fading a form out or in
Hello all. I've seen examples of this code all over the net. It doesn't work for me. I have an MDI child form with no control box, min or max buttons, and no title. It has a white background. It does not fade, it only closes after the timer expires. Anyone have a suggestion on this?
Thanks,
NumbLock
-
Apr 12th, 2011, 11:38 AM
#5
Re: vb.net--fading a form out or in
Try the one that I'd linked to in my sig: FadeGradientForm
-
Apr 12th, 2011, 01:30 PM
#6
New Member
Re: vb.net--fading a form out or in
Hello. Thanks for the reply. I might be misreading your post but it looks like it is for fading an MDI Container and not an MDI Child form. Am I missing something? I must admit, I didn't go through all the code, just from the details on the page you linked.
Thanks,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|