473,883 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2350
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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) 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.E lapsedEventArgs ) 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.Threa d.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
1806
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 am using transparent PNGs as background images of elements within the table. The following CSS is used to style two elements within the table: ..arrowLeft { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/core/images/arrow.png',
2
2454
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 before the smooth fading out. It never does it from 0.0 to 0.1, only from 1.0 to 0.99. Anyone seen this before?
6
3723
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 property at design time or in code just fine, but as soon as I move the form to a new location on the screen, it becomes completely opaque. If I then try to set the opacity property again, I get an error message. Any idea what's going wrong? Bob
1
4497
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 that looks like Adobe Acrobat's which appears to draw outside its bounds. To do this, I am setting the Transparency of the SplachScreen form to its background color and then drawing my screen (which appears to have no background). It looks really...
5
2913
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 src="someimage.jpg" name="myImage" id="myImage"> The alpha(opacity=50 does it in IE and the opacity: 0.50 does it Mozilla.
12
3790
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 (maybe looks like a sheet of green glass) but has elements or graphics on top that I want to be opaque. Perhaps I want the sheet of glass to have writing or other graphics "painted" on the surface. Is there some way to mix varying transparencies...
16
7464
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 System.Text; using System.Windows.Forms;
3
4299
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, it should be a better way to do it in fewer codes, right ? ( set all hover function to the same as form ? )
1
2028
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 black. And after it's opacity becomes one it becoems the normal color (Control). The code is as follows public Form1() { InitializeComponent(); this.Opacity = 0; }
0
10743
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
10847
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
10416
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9574
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...
1
7971
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7129
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5991
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4612
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
2
4220
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.