473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Opacity on form

I want a windows form to act like the one in Outlook when you get a new
message
and it is visible for about a couple of seconds and then the opacity
decreases and the form dissapears in the end
I have tried with
Dim p As Integer
Dim Vent As Integer
For p = 100 To 0 Step -1
Me.Opacity = p
For Vent = 1 To 100000
Next Vent
Next p
but the form is flickering and the opacity factor doesn't change.

reidarT
Jul 4 '06 #1
2 2330
try this code in VB, it wud solve ur problem
firstly declare a public variable p
e.g.

Public p As Integer = 100 ''here i predifine the initial opacity to
100%

Then in the form load event of the form, change the opacity to ANY
VALUE OTHER THAN 1(100% Opacity)..the best is 99.9% (i.e 0.999)
e.g.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Opacity = 0.999 ''this means opacity is set to 99.9%
End Sub

Then drop in a Timer control into tht form and write the following code
in the "elapsed" property of the timer :

Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
p = p - 1 'here i gradually decrease the opacity on evry
interval of the timer
Me.Opacity = (p / 100) 'convert my value to percentage by
dividing by 100
If Me.Opacity = 0.01 Then ''if opacity reaches 1% then close
the form
Me.Close()
End If
End Sub

Finally in the "interval" property of the timer, set ur own values
according to how fast or how slow u want the form to disappear.i used
1000 (i.e. 1000 millisecs = 1 second), so the opacity is decreased by
1% every one second,so..the form becomes invisible and finally closes
in 100 seconds.YOU CAN CHANGE THIS VALUE ACCORDING TO YOUR CONVINIENCE
AS HOW FAST/SLOW U NEED YOUR FORM TO CLOSE.
u can use 500 as interval..this will close your form in 50
seconds..value 100 will close your form in 10 seconds..and so
on.........

if u want to start the vanishing upon clicking a botton/event..then at
first disable the timer and enable it on that event being fired.
ok..gud luckk
Raj

reidarT wrote:
I want a windows form to act like the one in Outlook when you get a new
message
and it is visible for about a couple of seconds and then the opacity
decreases and the form dissapears in the end
I have tried with
Dim p As Integer
Dim Vent As Integer
For p = 100 To 0 Step -1
Me.Opacity = p
For Vent = 1 To 100000
Next Vent
Next p
but the form is flickering and the opacity factor doesn't change.

reidarT
Jul 4 '06 #2
It's as easy as this:
For p as integer = 100 to 0 step -1
Opacity = CDbl(p)/100
refresh
Threading.Thread.Sleep 100 'wait for 0,1 second
Next
reidarT wrote:
I want a windows form to act like the one in Outlook when you get a new
message
and it is visible for about a couple of seconds and then the opacity
decreases and the form dissapears in the end
I have tried with
Dim p As Integer
Dim Vent As Integer
For p = 100 To 0 Step -1
Me.Opacity = p
For Vent = 1 To 100000
Next Vent
Next p
but the form is flickering and the opacity factor doesn't change.

reidarT

Jul 8 '06 #3

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

Similar topics

1
by: chris | last post by:
I've used JavaScript DOM scripting to create a table element and alter its opacity. Bizarrely, the contents of the table appear to vanish when the opacity changes. One important note is that I...
2
by: Adam | last post by:
Hi everyone, I have a simple timer which decreases the Opacity from 1.0 to 0.0 and back again. The problem I have is, when it changes from 1.0 to 0.99, the whole form flickers completely...
6
by: Robert A. Boudra | last post by:
As you will probably guess, I'm just starting out with VB.net although I'm a long time VB developer. I was playing around with the Opacity property of a form and have found that I can set the...
1
by: Brian | last post by:
If your like me, you have probably seen way too many demos of the opacity property of a form. Well I finally have a need for it and I am having an issue. I am trying to create a splash screen...
5
by: Webmaster | last post by:
The following style sets the opacity or semi-transparency in Mozilla and Explorer browsers for an image: #myImage{ filter: alpha(opacity=50); -moz-opacity:0.50; opacity: 0.50; } <img...
12
by: Patrick Dugan | last post by:
I know that I can change the opacity of an entire form, but is there a way to control opacity to specific controls or components? For example I want to create a form that is semi-transparent...
16
Atran
by: Atran | last post by:
Hello EveryBody, I write this code but the code not work: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using...
3
by: Boki | last post by:
Hi All, I saw the paint.net program, when mouse hover, the color palette become 100% opacity. I try the code below, the issue is I also have some other controls ( textbox/button ) in my form,...
1
by: akshaycjoshi | last post by:
I am ShowDialoging one form in which the activate event increases the opacity from 0 to 1. I set the opacity to 0 in it's constructor.The problem is that during the showing of the form it becomes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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...

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.