Track Form background Color : Color « 2D « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » 2D » ColorScreenshots 
Track Form background Color
Track Form background Color

Imports System.Windows.Forms
Imports System.Drawing


Module Module1

    Sub Main()
        Application.Run(New Form1)
    End Sub

End Module



Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is NothingThen
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents TrackBar1 As System.Windows.Forms.TrackBar
    Friend WithEvents TrackBar2 As System.Windows.Forms.TrackBar
    Friend WithEvents TrackBar3 As System.Windows.Forms.TrackBar
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.TrackBar1 = New System.Windows.Forms.TrackBar()
        Me.TrackBar2 = New System.Windows.Forms.TrackBar()
        Me.TrackBar3 = New System.Windows.Forms.TrackBar()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        CType(Me.TrackBar1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.TrackBar2, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.TrackBar3, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(2030)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(5623)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Red"
        '
        'TrackBar1
        '
        Me.TrackBar1.Location = New System.Drawing.Point(8030)
        Me.TrackBar1.Maximum = 255
        Me.TrackBar1.Name = "TrackBar1"
        Me.TrackBar1.Size = New System.Drawing.Size(18034)
        Me.TrackBar1.TabIndex = 2
        Me.TrackBar1.TickFrequency = 25
        '
        'TrackBar2
        '
        Me.TrackBar2.Location = New System.Drawing.Point(8080)
        Me.TrackBar2.Maximum = 255
        Me.TrackBar2.Name = "TrackBar2"
        Me.TrackBar2.Size = New System.Drawing.Size(18034)
        Me.TrackBar2.TabIndex = 5
        Me.TrackBar2.TickFrequency = 25
        '
        'TrackBar3
        '
        Me.TrackBar3.Location = New System.Drawing.Point(80130)
        Me.TrackBar3.Maximum = 255
        Me.TrackBar3.Name = "TrackBar3"
        Me.TrackBar3.Size = New System.Drawing.Size(18034)
        Me.TrackBar3.TabIndex = 3
        Me.TrackBar3.TickFrequency = 25
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(2080)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(4823)
        Me.Label2.TabIndex = 4
        Me.Label2.Text = "Green"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(20130)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(5623)
        Me.Label3.TabIndex = 5
        Me.Label3.Text = "Blue"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(513)
        Me.ClientSize = New System.Drawing.Size(292273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label3, Me.Label2, Me.TrackBar3, Me.TrackBar2, Me.TrackBar1, Me.Label1})
        Me.Name = "Form1"
        Me.Text = "TrackBarDemo"
        CType(Me.TrackBar1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.TrackBar2, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.TrackBar3, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Red As Byte
    Public Green As Byte
    Public Blue As Byte
    Public Background As Color

    Private Sub TrackBar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgsHandles TrackBar1.ValueChanged
        Red = TrackBar1.Value
        Background = Color.FromArgb(Red, Green, Blue)

        RefreshBackground()
    End Sub


    Private Sub TrackBar2_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgsHandles TrackBar2.ValueChanged
        Green = TrackBar2.Value
        Background = Color.FromArgb(Red, Green, Blue)
        
        RefreshBackground()
    End Sub


    Private Sub TrackBar3_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgsHandles TrackBar3.ValueChanged
        Blue = TrackBar3.Value
        Background = Color.FromArgb(Red, Green, Blue)

        RefreshBackground()
    End Sub

    Private Sub Form1_Activated(ByVal sender As System.Object, ByVal e As System.EventArgsHandles MyBase.Activated
        Red = Form1.ActiveForm.BackColor.R
        Green = Form1.ActiveForm.BackColor.G
        Blue = Form1.ActiveForm.BackColor.B
        TrackBar1.Value = Red
        TrackBar2.Value = Green
        TrackBar3.Value = Blue
    End Sub

    Private Sub RefreshBackground()
        Form1.ActiveForm.BackColor = Background
        Form1.ActiveForm.Refresh()
    
    End Sub
End Class

           
       
Related examples in the same category
1.Get all Known color and calcuate its Brightness and SaturationGet all Known color and calcuate its Brightness and Saturation
2.Using different colors in Visual BasicUsing different colors in Visual Basic
3.Color Dialog: Changing the background and text colors of a formColor Dialog: Changing the background and text colors of a form
4.Construct Color from R G B ValueConstruct Color from R G B Value
5.Use color dialog to set form backgroundUse color dialog to set form background
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.