473,698 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Fade-In Form

Hey guys I am trying to fade in a form using the following code:

Public Class frmAbout
Inherits System.Windows. Forms.Form

Dim i As Integer 'Public Variable

#Region The Windows Form code...
Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal e As
System.EventArg s) Handles Timer1.Tick
If i < 100 Then
i = i + 1
Me.Opacity = i / 100
Else
Timer1.Stop()
End If
End Sub
End Class

I tried adjusting my timer to various values (currently 500000 as I am
not sure what this number corresponds to) and my timer is started in my
form initialization code. Yet my form does not fade in, it kinda blinks
and just appears. In the function that creates the form I have:

Dim objAbout = New frmAbout()
objAbout.MdiPar ent = Me
objAbout.Show()

Any ideas on why my form is not fading in?
(THe opacity is set to 0 in the properties window in design view of the
form)

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05
14 2265
just a little bug to that, the opacity only reaches .99 at the end, you
might want to make a better loop or set the opacity at the end of the fadein
sub to be 1..
also the step will change how much the fade does to, like .01 does 100
levels of fade, while .1 does only 10...
"Brian Henry" <[REMOVE-ME]br******@adelph ia.net> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
do somethign similar to this

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim fadeThread As New System.Threadin g.Thread(Addres sOf fadeIn)

fadeThread.Star t()

End Sub

Public Sub fadeIn()

Application.DoE vents()

Me.Refresh()

For x As Double = 0 To 1.0 Step 0.01

Me.Opacity = x

System.Threadin g.Thread.Sleep( 50)

Next

End Sub

"Ivan Weiss" <iv*****@optonl ine.net> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I tried moving my code to the activated method after reading a reference
noticing that the form load method runs before the form is painted so
the code would be useless there.

No luck with the following code:

Maybe e-mailing you the actual code would help. I am so confused with
this problem.

Private Sub frmAbout_Activa ted(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Activate d
Dim i As Double = 0.0

While i < 1.0
'Application.Do Events()
Me.Opacity = i
i = i + 0.01
System.Threadin g.Thread.Sleep( 50)
End While
'Me.Opacity = 1
End Sub

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 20 '05 #11
Hi Ivan,

That is the answer - I was having the same problem - simply do not set a
parent and the form will fade in just fine.

HTH,

Bernie Yaeger

"Ivan Weiss" <iv*****@optonl ine.net> wrote in message
news:Oq******** ******@TK2MSFTN GP11.phx.gbl...
I think what is happening is that when I call the show method of the
About form from my menu (main MDI Form) it is running this code before
the form actually shows. I am not sure but I think that is what the
problem is.

The structure is:

User Clicks on Help-->About Menu Item
I create a new About form object and set its mdi parent to the main MDI
form.
I than call objAbout.Show()
the code to fade-in my form is in the frmAbout_Load event.

Maybe it is this structure that is giving me my trouble?

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #12
On Sun, 14 Dec 2003 18:07:49 -0800, Ivan Weiss wrote:
For i = 0.0 To i >= 1.0


This syntax makes no sense to me. The i >= 1.0 clause will evaluate to a
boolean False. So you're really saying For i = 0.0 To False. That makes
no sense to me. Do you have Option Strict On?

Try this:

Dim i as Double

For i = 0.0 to 1.0 Step 0.01
Me.Opacity = i
System.Threadin g.Thread.Sleep( 500)
Next

Does that make any difference?

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #13
u know that works and all but it will never reach 1.0 ;) stepping by .01
will get you up to .99 then drop out... duno why exactly.. but it does...
look at the code i posted... it only getsup to 99% opacity when i tested it
many times... had to manually set it to 1.0 myself to get 100%
"Chris Dunaway" <dunawayc@_lunc hmeat_sbcglobal .net> wrote in message
news:1l******** *************** *****@40tude.ne t...
On Sun, 14 Dec 2003 18:07:49 -0800, Ivan Weiss wrote:
For i = 0.0 To i >= 1.0


This syntax makes no sense to me. The i >= 1.0 clause will evaluate to a
boolean False. So you're really saying For i = 0.0 To False. That makes
no sense to me. Do you have Option Strict On?

Try this:

Dim i as Double

For i = 0.0 to 1.0 Step 0.01
Me.Opacity = i
System.Threadin g.Thread.Sleep( 500)
Next

Does that make any difference?

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #14
u know that works and all but it will never reach 1.0 ;) stepping by .01
will get you up to .99 then drop out... duno why exactly.. but it does...
look at the code i posted... it only getsup to 99% opacity when i tested it
many times... had to manually set it to 1.0 myself to get 100%
"Chris Dunaway" <dunawayc@_lunc hmeat_sbcglobal .net> wrote in message
news:1l******** *************** *****@40tude.ne t...
On Sun, 14 Dec 2003 18:07:49 -0800, Ivan Weiss wrote:
For i = 0.0 To i >= 1.0


This syntax makes no sense to me. The i >= 1.0 clause will evaluate to a
boolean False. So you're really saying For i = 0.0 To False. That makes
no sense to me. Do you have Option Strict On?

Try this:

Dim i as Double

For i = 0.0 to 1.0 Step 0.01
Me.Opacity = i
System.Threadin g.Thread.Sleep( 500)
Next

Does that make any difference?

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1664
by: Acer | last post by:
Does somebody know a javascript function to show an image and fade-out to another picture ? thanks for any help
2
2068
by: Harshal | last post by:
Hello, I have following html file <html> <head> <script> var flag = true; function LoadNewImage()
2
1790
by: localhost | last post by:
I want to read an image from disk, get the total width, and then find the bottom region (say an area of 120 high x the total width) and fade-away each pixel by a percentage to white, and then output that memory-modified image to the HTTP stream. Where should I look for info or samples on doing that? Thanks.
1
3089
by: Theseus | last post by:
Hello to all, I've got an issue where i don't know what solution i can implement. I'm not sure what script best can be used. I've got samples .jpg images to better describe my problem. Stage 1: http://img509.imageshack.us/img509/7139/stage16ht.jpg Stage 2:
1
1432
by: Michael | last post by:
I would like to create my own system that allows dragging and dropping, into different cells of a table, much like Yahoo's implementation here: http://developer.yahoo.com/yui/dragdrop/index.html , however I can't use that because there can't be any strings attached, at all. If someone could give me some helpful links or tutorials for this I would be very grateful. Likewise I also need to create a fading system (cross-browser) so if...
1
2002
by: John Smith | last post by:
I'm looking for javascript that will rotate 3-6 jpg images with a fade to white transition between images. I've got a script that will handle the rotation but not the fade. Maybe it can't be done with JS? Thanks!
3
14430
by: virgil46 | last post by:
How do I for instance, fade the background color from dark gold at the top of the page to a light gold, by the time it gets to the bottom of the page?
5
3272
by: Gretsch | last post by:
Hi, Can someone help me with the command format please. I have a function (called fade) that was 3 parameters: the first 2 are colours therefore formatted #123456 and the 3rd is a number of milliseconds. A normal call to the function therefore looks like this:
4
4955
by: pt36 | last post by:
Hi I have a small script function photo(a){ var photo = a ; document.getElementById(photoID).innerHTML = photo; } and on the body
3
3512
toxicpaint
by: toxicpaint | last post by:
Hi Everyone, I've had a look around but couldn't find any answers so thought I'd ask you lot. :) I'm using actionscript 2.0. What I have on my stage is a button that when you mouse over it, pops up a movie clip. Then when you move you mouse off it, it disappears after about 3 seconds. What I'd like it to do is fade out after 3 seconds rather than disappearing. For some reason this seems to be pretty much impossible with my existing code....
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.