NiftyHost Forums (Archive)
Make a custom window design in visual basic - Printable Version

+- NiftyHost Forums (Archive) (https://niftyhost.chary.us/support)
+-- Forum: Technology (https://niftyhost.chary.us/support/forum-7.html)
+--- Forum: Coding (https://niftyhost.chary.us/support/forum-12.html)
+--- Thread: Make a custom window design in visual basic (/thread-1292.html)



Make a custom window design in visual basic - man007 - 08-05-2011

I am a visual basic programmer so I decited to share some of my knowlege with you. I will tell you how to make a custom window design.
Ok it is very simple... First of all, change the FormBorgerStyle to none. Then add a panel. Now add this code after the Private Class Form1 :
Code:
Dim A As New System.Drawing.Point()
    Dim x, y As Integer
    Dim i As String = 0
    Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
        x = Control.MousePosition.X - Me.Location.X
        y = Control.MousePosition.Y - Me.Location.Y
    End Sub
    Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
        If e.Button = MouseButtons.Left Then
            A = Control.MousePosition
            A.X -= (x)
            A.Y -= (y)
            Me.Location = A
        End If
    End Sub
What is this doing?
This move the form when you hold and move the panel you endered...
Now add three picturebox which will minimize,maximize and close the form...
- To the picturebox that will minimize the form add this code :
Code:
Me.WindowState = FormWindowState.Minimized
- To the picturebox that will maximize the form add the this code :
Code:
i = i + 1
        If i = 1 Then
            Me.WindowState = FormWindowState.Maximized
        End If
        If i = 2 Then
            Me.WindowState = FormWindowState.Normal
            i = 0
        End If
and the code "Dim i As String = 0" after the Private Class Form1.

- To the picturebox that will close the form add the this code :
Code:
End
That’s it!!!

If you have problem to create your custom form design download an example I have made for you :
http://adf.ly/18UqS

If you have any question ask me here! :)