Solved

Splash form - two triangles that go from Green to Blue

Posted on 2006-07-23
5
239 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML - Color not displaying correctly in EMAIL. 6 49
Import Data from Multiple Text Files in Excel 12 60
No Data for DropDown List 2 28
Visual studio 2015 1 21
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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

839 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