Solved

Splash form - two triangles that go from Green to Blue

Posted on 2006-07-23
5
242 Views
Last Modified: 2010-07-27
I need to have the background color for my splash form go from Green (0 to 255) to Blue (255 to 0). I found the code in a previous post but it doesn't work. It still displays what was produced when I tried to make the splash form. The code I used is this:

Private Sub frmSplash_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

        Dim rect As Rectangle = New Rectangle(20, 20, 200, 100)
        Dim path As GraphicsPath
        Dim region As Region
        Dim brush As LinearGradientBrush

        path = New GraphicsPath(FillMode.Alternate)
        path.AddLine(rect.Left, rect.Bottom, rect.Left, rect.Top)
        path.AddLine(rect.Left, rect.Top, rect.Right, rect.Top)
        path.AddLine(rect.Right, rect.Top, rect.Left, rect.Bottom)

        region = New Region(path)
        brush = New LinearGradientBrush(rect, Color.Black, Color.Green, LinearGradientMode.Horizontal)

        e.Graphics.Clip = region
        e.Graphics.FillRectangle(brush, rect)


        path = New GraphicsPath(FillMode.Alternate)
        path.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom)
        path.AddLine(rect.Right, rect.Bottom, rect.Left, rect.Bottom)
        path.AddLine(rect.Left, rect.Bottom, rect.Right, rect.Top)

        region = New Region(path)
        brush = New LinearGradientBrush(rect, Color.Blue, Color.Black, LinearGradientMode.Horizontal)

        e.Graphics.Clip = region
        e.Graphics.FillRectangle(brush, rect)

        brush = New LinearGradientBrush(rect, Color.Blue, Color.Black, LinearGradientMode.Horizontal)
        brush.GammaCorrection = True          ' add this line
    End Sub

  What this produces are rectangles, two green then one blue. The rectangles then have diamond shapes inside of them. Any help would be greatly appreciated!
0
Comment
Question by:smstrks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 500 total points
ID: 17166102
>> I need to have the background color for my splash form go from Green (0 to 255) to Blue (255 to 0)
If you want just that, I don't think you need to create Rectangles and color them, Also what do you mean "GO FROM"
do you want it turn gradually say in a few seconds from Green to Blue ?
If yes you need a Timer

On Form Load have this....

        Dim ColorTimer As New Timer
        ColorTimer.Interval = 100
        BackColor = Color.FromArgb(0, 255, 0)
        AddHandler ColorTimer.Tick, AddressOf ColorTimer_Tick
        ColorTimer.Start()

Then have this Event Handler....

       Private Sub ColorTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If BackColor.G <= 0 Then
            CType(sender, Timer).Stop()
            Exit Sub
        End If

Run and wait for a 10-15 secs to see the effect

        BackColor = Color.FromArgb(0, BackColor.G - 1, BackColor.B + 1)
    End Sub

0
 

Author Comment

by:smstrks
ID: 17400043
Sorry! My computer crashed and I could not remember the url for this website!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question