473,566 Members | 2,763 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 #1
14 2255
Ivan:

I have an article over here
http://www.knowdotnet.com/testsite/a...s/opacity.html . It's in C# but it
should help. BTW, we are still proofing the grammar, but the code is
correct. HTH,

Bill
"Ivan Weiss" <iv*****@optonl ine.net> wrote in message
news:Of******** ******@TK2MSFTN GP11.phx.gbl...
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 #2
Ivan:

Also, you may want to move the Sleep increment down to 70 or even 50
depending on how fast/slow your machine works, but this can defintiely do it
without flicker.

HTH,

Bill
"Ivan Weiss" <iv*****@optonl ine.net> wrote in message
news:Of******** ******@TK2MSFTN GP11.phx.gbl...
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 #3
I tried inserting this code into my form_load and removing my other code
utilizing the timer:

Dim i As Double = 0.0

For i = 0.0 To i >= 1.0
Me.Opacity = i
i = i + 0.1
System.Threadin g.Thread.Sleep( 500)
Next
Me.Opacity = 1

However, it does the same thing. It kind of hesitates and than just
shows up, there is no fade in.

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4
Change the 500 to 50 for instance. It may be your video card isn't
processing it quickly. I've run this on quite a few machines and at 500
it's somewhat choppy but it's not that bad. At 100 it's pretty smooth and
at 70 it's the exact effect I want. If you go too low, it happens too
quickly. Too slow and it's choppy.

You may also want to play with the increment. I have it set at .1. but you
can change it to .05 for instance, or even .01 to fine tune it. If you use
a smaller increment though, don't use 500 for the thread, it'll be 10 times
as long at .01 and twice as long at .05. I'd move the sleep to 100 first,
if that doesn't do it, try 70, then maybe 50. If it's still choppy, go back
start at like 200 and play with the increment. It's going to be a matter of
playing with it, but remember that you may want to make it adjustable b/c
different video cards draw things at different speeds and the users may want
the ability to manipulate it themseleves.

One other thing.... Try adding a DoEvents in the loop. Normally I refrain
from this, but I'm thinking it may help in this case.

Let me know.

Bill
"Ivan Weiss" <iv*****@optonl ine.net> wrote in message
news:Of******** ********@TK2MSF TNGP10.phx.gbl. ..
I tried inserting this code into my form_load and removing my other code
utilizing the timer:

Dim i As Double = 0.0

For i = 0.0 To i >= 1.0
Me.Opacity = i
i = i + 0.1
System.Threadin g.Thread.Sleep( 500)
Next
Me.Opacity = 1

However, it does the same thing. It kind of hesitates and than just
shows up, there is no fade in.

-Ivan

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

Nov 20 '05 #5
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 #6
put an application.doe vents() in the loop, this causes all the events in the
queue to process... sometimes that holds up paining of forms if you dont do
it when its in a loop
"Ivan Weiss" <iv*****@optonl ine.net> wrote in message
news:Of******** ********@TK2MSF TNGP10.phx.gbl. ..
I tried inserting this code into my form_load and removing my other code
utilizing the timer:

Dim i As Double = 0.0

For i = 0.0 To i >= 1.0
Me.Opacity = i
i = i + 0.1
System.Threadin g.Thread.Sleep( 500)
Next
Me.Opacity = 1

However, it does the same thing. It kind of hesitates and than just
shows up, there is no fade in.

-Ivan

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

Nov 20 '05 #7
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 #8
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 #9
you will have to set the initial opacity to zero also, using a thread like
this makes the form usable while it fades in also... change the sleep time
to make it go faster also
"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 #10

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

Similar topics

1
1658
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
2063
by: Harshal | last post by:
Hello, I have following html file <html> <head> <script> var flag = true; function LoadNewImage()
2
1787
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
3075
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
1425
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...
1
1996
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
14425
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
3270
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
4950
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
3506
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...
0
7666
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...
0
7888
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. ...
0
8108
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...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.