Solved

Splash form - two triangles that go from Green to Blue

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now