Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How we can make Custom Color Form in VB.Net

Author: DevASP
Download Source Code : 544_CustomColorsForms.zip

We can Change Color Of form by Paint Colors. These Color Are Not simple Colors. With this technique you can make your Gradient Color forms.Because it changes the color of form dynamically you can set.

Write these lines code in parent forms load event

 

For Each MdiCtl As MdiClient In Controls

Dim MdiPainter As New MdiContainer(MdiCtl)

Next

 With Me

       frmChild = New Form2

       frmChild.MdiParent = Me

      .frmChild.Show()

    .frmChild.SetDesktopBounds(35, 35, .frmChild.Width,rmChild.Height)

 End With

 

This function infact set form as parent form and set its bound on desktop. Now just make that region.this region code is important please copy it carefully.Handles painting of the MdiClient(ie: the mdiform it's self )

 

#Region " MdiClient Paint Handling Class " '

Public Class MdiContainer

    Inherits Control

    Private WithEvents MdiPane As Control

 

    Public Sub New(ByVal ctl As Control)

        MdiPane = DirectCast(ctl, Control)

End Sub

 

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

 

Dim rect As New Rectangle(0, 0, MdiPane.Width, MdiPane.Height)

Dim b As New System.Drawing.Drawing2D.LinearGradientBrush(rect, Color.FromArgb(Color.Violet.A, Color.Violet.R, Color.Violet.G, Color.Violet.B), Color.FromArgb(255, 0, 72, 160),

Drawing2D.LinearGradientMode.Horizontal Or

 

Drawing2D.LinearGradientMode.ForwardDiagonal)

 

e.Graphics.FillRectangle(b, rect)

e.Graphics.Dispose()

End Sub

 

 

 Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

        If disposing Then

            If Not (MdiPane Is Nothing) Then

                MdiPane.Dispose()

            End If

        End If

        MyBase.Dispose(disposing)

    End Sub

 

Private Sub MdiPane_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MdiPane.Resize

 

 Dim frm As Form = DirectCast(MdiPane.Parent, Form)

    If Not frm.WindowState = FormWindowState.Minimized Then

      Dim g As Graphics = MdiPane.CreateGraphics

      Dim rect As New Rectangle(0, 0, MdiPane.Width, MdiPane.Height)

Dim b As New System.Drawing.Drawing2D.LinearGradientBrush(rect, Color.FromArgb(Color.Violet.A, Color.Violet.R, Color.Violet.G, Color.Violet.B), Color.FromArgb(255, 0, 72, 160),

 

Drawing2D.LinearGradientMode.Horizontal Or Drawing2D.LinearGradientMode.ForwardDiagonal)

g.FillRectangle(b, rect)

g.Dispose()

   End If

        frm = Nothing

    End Sub

End Class

 

#End Region

 

Source code is given with these article .And theses Functions Are Given in attached application. It is recommended run application first. In this Article I tried to explain Custom Color Forms Using vb.net, there are many other Methods in VB.net I Prefer it.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How - To Remoting - Client Server Using VB.Net (Part Two)

Disclaimer - Privacy
© 2002-2017 DevASP.net