Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 1st, 2007, 06:27 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default Hello! And A Question on Form Opacity...

First Off, I would just like to say Hello! to the C# forum, I have recently started my MCP In Developing Windows Apps in C# (working towards MCAD) so I thought I will try and get involved in this forum as well as the Office Development forum that I normally lurk around in. So Hello!

I have recently got on to visual inheritance, which seems like it could be very powerful and useful in terms of producing a "standard" interface for an application. So I thought, "how could I use this to make an app a little more interesting?"..

So I thought, "how about a form that fades in and out on open/close?" seems like a great idea to me! So I started putting some code together, I have the form fading in nicely on open, by simple calling the fade code from its constructor.. Its the close that is causing me the problem!

Apologies, I cant post my current code as I am at work and stupid me didnt bring it in, but I have looked on the net, and all the suggestions/ideas seems to indicate that a fade out is only possible via multithreading.. is this the case?

Just wondered if anyone else had any ideas/facts on the issue.

I tried to do it using a loop and Application.DoEvents, the timer event seems to be firing in this loop, but much slower, and the form is not being repainted. I added a forced repaint, then it just flickered and looked awful!!

All comments and suggestions gratefully recieved!

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
__________________
Rob
http://cantgrokwontgrok.blogspot.com
 
Old August 1st, 2007, 08:10 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Welcome!
Quote:
quote:Originally posted by robzyc
 So I thought, "how about a form that fades in and out on open/close?"

Solution: Install Vista ;)

Seriously though...

Presumably doing what you are doing in the constructor backwards doesn't work then? Could the problem be that the fade out code is running on the unload/hide EVENT (which fires after the main unload/hide method)? Maybe you need to override the unload/hide method, do the fade, then call the base's unload/hide.

-Peter
 
Old August 1st, 2007, 08:42 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Peter,

Yeah, I want Vista, but I need a new box for it and haven't really got the money to burn at the moment! :(

What I basically have is the fade in code in the Form_Load and the fade out in the Form_Closing events..

All they do is activate a timer, which then adds a value (the gradient) to a member field, which is then used to set the opacity level.

As I said, works fine on the load, but when the Closing event fires, its doing that, closing, and (from what I can see) there is no way to suspend the actual closing until the fade is complete...

I have had a brainwave though.. What if I was to cancel the close (in the closing event, using the event args) but set a field to CloseOnceFadeComplete to true.. and then the fade routine can pick this up and force a form close... ?? what do you think?

Hope I explained that clear enough (yeah right! :D) if you have any Q's then please shout!

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
 
Old August 1st, 2007, 10:08 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I imagine that should work.

If you can cancel the close event then fire off the fade-then-close. You'll need to add a check to the close event however that checks a flag set at the end of the fade routine. Otherwise, you'll end up with a endlessly fading window that will never close!

-Peter
 
Old August 1st, 2007, 11:05 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

I'll give it a whirl tonight!

Would be a nice-to-have, not quite a **************** Vista app, but may still look nice!

I'll keep you posted!

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>





Similar Threads
Thread Thread Starter Forum Replies Last Post
oPacity Mouseover crmpicco Javascript How-To 3 July 1st, 2005 09:43 AM
Form question Scott Rider General .NET 4 June 30th, 2005 08:04 AM
Opacity dinosaur_uk VB.NET 2002/2003 Basics 1 September 24th, 2004 10:03 AM
Form question dsealer Access 7 September 14th, 2004 12:36 PM
Login form question Jams30 PHP Databases 1 December 4th, 2003 12:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.