• Log in or sign up for an account here: https://www.sythe.org/login

How to give your program cool fading effects when you close \ load

  • Thread starter Thread starter The True Gears
  • Start date Start date
T

The True Gears

Guest
Put this code in Form1_load \ Form1_formclosing

Code:
        Dim fade As Double
        For fade = 0.0 To 1.1 Step 0.1
            Me.Opacity = fade
            Me.Refresh()
            Threading.Thread.Sleep(100)
        Next

Gives a pretty 1337 effect that most programs don't have :D
 
thanks :D i will definitely use this in my programs
good job
 
Form closing:
Code:
Dim fade As Double
        For fade = 1.1 To 0.0 Step -0.1
            Me.Opacity = fade
            Me.Refresh()
            Threading.Thread.Sleep(100)
        Next
that will make it fade out instead of fade in.
 
Member of the Month Winner
Sythe's 10th Anniversary
Terribly simple, however a lot of people seem to lack the ability to study such simple things, so I guess I can credit you for teaching.

100ms sleep time is a bit much for fading. Perhaps 25 would do.
Anyhow, converted to C#.

fade in:
Code:
for(float fade = 0.0f; fade <= 1.1f; fade += 0.1f)
{
    this.Opacity = fade;
    this.Invalidate();
    this.Update();
    System.Threading.Thread.Sleep(25);
}

fade out:
Code:
for(float fade = 1.1f; fade > 0.0f; fade -= 0.1f)
{
    this.Opacity = fade;
    this.Invalidate();
    this.Update();
    System.Threading.Thread.Sleep(25);
}

I will point out that this is useless in Windows Vista, as the window manager already has such effects, except they are much more "aesthetically pleasing".
 
Don't bug me about it...my point of posted it was to help new users...doesn't mean im one
 
Member of the Month Winner
Sythe's 10th Anniversary
I' am new to VB and this totally rocks!
 
Terribly simple, however a lot of people seem to lack the ability to study such simple things, so I guess I can credit you for teaching.

100ms sleep time is a bit much for fading. Perhaps 25 would do.
Anyhow, converted to C#.

fade in:
Code:
for(float fade = 0.0f; fade <= 1.1f; fade += 0.1f)
{
    this.Opacity = fade;
    this.Invalidate();
    this.Update();
    System.Threading.Thread.Sleep(25);
}

fade out:
Code:
for(float fade = 1.1f; fade > 0.0f; fade -= 0.1f)
{
    this.Opacity = fade;
    this.Invalidate();
    this.Update();
    System.Threading.Thread.Sleep(25);
}

I will point out that this is useless in Windows Vista, as the window manager already has such effects, except they are much more "aesthetically pleasing".

Thanks for the C# code :P
this. never seems to work for me, but just putting opacity = fade; works
 
Member of the Month Winner
Sythe's 10th Anniversary
Thanks for the C# code :P
this. never seems to work for me, but just putting opacity = fade; works
'this' is the keyword which refers to the containing class.

i.e. in a class called MyClass, with an integer member called 'myint', you could refer to myint like so:

Code:
this.myint
 
This thread is about as old as the internet, this is from when I actually cared about coding.

I used to type like I was in 3rd grade ;_;
 
duelarena.gg
Back
Top