B
Brian
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
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