473,396 Members | 1,773 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,396 software developers and data experts.

Help with Opacity and TransparencyKey

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
cool but I now want the screen to fade out on close. To do this I am slowly
changing the opacity of the form. Now for the issue:

As the opacity changes the background color is also changed and no longer
matches the TransparencyKey which results in the form being visible during
the fade out. How can I fix this? Is there a way to calculate the
resulting color of after opacity transformation?

Thanks,

Brian
Private Sub SplashScreen_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.TransparencyKey = Me.BackColor
Dim DelayedCloser As New Closer(AddressOf DelayedClose)
DelayedCloser.BeginInvoke(Nothing, Nothing)
End Sub

Private Sub SplashScreen_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
e.Graphics.FillRectangle(Brushes.Khaki, New Rectangle(100, 0, 300,
200))
e.Graphics.DrawString("Logo", New Font("Arial", 36, FontStyle.Bold,
GraphicsUnit.Pixel), Brushes.Navy, 105, 10)
e.Graphics.DrawLine(Pens.Navy, 0, 50, 200, 50)
e.Graphics.DrawLine(Pens.Navy, 25, 55, 200, 55)
e.Graphics.DrawLine(Pens.Navy, 50, 60, 200, 60)
End Sub

Private Delegate Sub Closer()

Private Sub DelayedClose()
Threading.Thread.CurrentThread.Sleep(2000)
For o As Double = 1.0 To 0.0 Step -0.1
Me.Opacity = o
Threading.Thread.CurrentThread.Sleep(10)
Next
Me.Close()
End Sub
Nov 21 '05 #1
1 4464
Changing the background color of the form to white fixes the problem (white
is not effected by the opacity).

I would still like to know how to calculate the resulting color after
opacity is changed. If anybody out there knows, please let me know.
"Brian" <bb******@optonline.net> wrote in message
news:OP**************@TK2MSFTNGP15.phx.gbl...
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
cool but I now want the screen to fade out on close. To do this I am
slowly changing the opacity of the form. Now for the issue:

As the opacity changes the background color is also changed and no longer
matches the TransparencyKey which results in the form being visible during
the fade out. How can I fix this? Is there a way to calculate the
resulting color of after opacity transformation?

Thanks,

Brian
Private Sub SplashScreen_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.TransparencyKey = Me.BackColor
Dim DelayedCloser As New Closer(AddressOf DelayedClose)
DelayedCloser.BeginInvoke(Nothing, Nothing)
End Sub

Private Sub SplashScreen_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
e.Graphics.FillRectangle(Brushes.Khaki, New Rectangle(100, 0, 300,
200))
e.Graphics.DrawString("Logo", New Font("Arial", 36, FontStyle.Bold,
GraphicsUnit.Pixel), Brushes.Navy, 105, 10)
e.Graphics.DrawLine(Pens.Navy, 0, 50, 200, 50)
e.Graphics.DrawLine(Pens.Navy, 25, 55, 200, 55)
e.Graphics.DrawLine(Pens.Navy, 50, 60, 200, 60)
End Sub

Private Delegate Sub Closer()

Private Sub DelayedClose()
Threading.Thread.CurrentThread.Sleep(2000)
For o As Double = 1.0 To 0.0 Step -0.1
Me.Opacity = o
Threading.Thread.CurrentThread.Sleep(10)
Next
Me.Close()
End Sub

Nov 21 '05 #2

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

Similar topics

2
by: MyNameIsnt | last post by:
Can anyone tell me why, when I click on the buttons it register 2 characters on the display? if you use the right mousebutton it works ok, but the buttons dont flash?? it works fine without the...
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...
5
by: Brian Shafer | last post by:
Ok, I was playing around with this feature. have it set at 100% now.. but still looks like it is 50% when I run it.... What other feature did i set that is preventing this from resetting? Brian
10
by: lindmark.daniel | last post by:
Since I'm a mac-head, I don't have the possibility to make this little script I wrote work proper on a MSIE browser. I know there's smarts in here that easily could spot my f**k ups and tell me...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: kidelectric | last post by:
The issue I am having is that I would like to be able to drag-and-drop div elements that have rounded corners.* Since these elements will be dynamically created (including background color), I could...
7
by: Dayo | last post by:
Hello folks. Sorry if this seems a bit silly, I have no experience with this type of code. Here is a fading script for an Image Gallery I am looking to fix. It works with IE and Safari but not...
2
by: shawnwperkins | last post by:
Hi Folks, I'm new to Javascript and just need a little help. I downloaded a script from Dynamic Drive's Web site and I'm trying to make a simple modification and could use some help. :) The...
8
by: Rainer Queck | last post by:
Hello NG, I had/have a bad flicker Problem with my Application. On starting some applications, while my app was running, the whole Display started to flicker. Even the desktop Icons! Looking...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...

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.