blah blah blah is here! blah blah » Close

up0down
link

I have this program that when I press the X button at the top of the screen (In Normal application close the program) I wish to change the opacity. how to do it please? I am trying to find some us full code. Thanks very much in advance to your support

last answered 2 years ago

1 answers

up0down
link

override OnClosing, set e.Cancel = true and set the form transparency.

up0down
link

I have a context menu How to I make that exit to work (Shutting down the program).
or shell i Use a variable a use and if statement

up0down
link

lets say u want to make the form disappear slowly then drag and drop a timer for this, then in the form_Load event handler write down this:
timer1.Interval=50;
timer1.Enabled=false;
this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
this.timer1.Tick += new System.EventHandler(timer1_Tick);
then in the Form1_FormClosing event handler write down this:
e.cancel=true;
timer1.Enabled=true;;
and in the timer1_Tick event handler write down this:
this.Opacity -= 0.1;
if (this.Opacity <= 0)
{
Application.Exit();
}
then u'll have what u want, but there is one thing, u were talking about context menu. so if u ment exit menuitem in the context menu, try maing its evenet handler do this:
this.Close();
and this would be enough

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback