Click here to Skip to main content
15,884,425 members
Articles / Programming Languages / Visual Basic

Drag and Resize - Borderless Form

Rate me:
Please Sign up or sign in to vote.
4.71/5 (5 votes)
17 Dec 2012CPOL1 min read 51.1K   5.2K   8  
This code allows to drag and resize a borderless form!
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Borderless
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    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.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.labelName = New System.Windows.Forms.Label()
        Me.panel1 = New System.Windows.Forms.Panel()
        Me.buttonMin = New System.Windows.Forms.Button()
        Me.buttonClos = New System.Windows.Forms.Button()
        Me.buttonMax = New System.Windows.Forms.Button()
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.panel1.SuspendLayout()
        Me.SuspendLayout()
        '
        'labelName
        '
        Me.labelName.AutoSize = True
        Me.labelName.BackColor = System.Drawing.Color.Transparent
        Me.labelName.Font = New System.Drawing.Font("Georgia", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(238, Byte))
        Me.labelName.Location = New System.Drawing.Point(9, 6)
        Me.labelName.Name = "labelName"
        Me.labelName.Size = New System.Drawing.Size(106, 15)
        Me.labelName.TabIndex = 5
        Me.labelName.Text = "Selfmade Form"
        '
        'panel1
        '
        Me.panel1.Anchor = System.Windows.Forms.AnchorStyles.None
        Me.panel1.BackgroundImage = Global.Borderless_Form.My.Resources.Resources.Orange
        Me.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
        Me.panel1.Controls.Add(Me.labelName)
        Me.panel1.Controls.Add(Me.buttonMin)
        Me.panel1.Controls.Add(Me.buttonClos)
        Me.panel1.Controls.Add(Me.buttonMax)
        Me.panel1.Location = New System.Drawing.Point(3, 3)
        Me.panel1.Name = "panel1"
        Me.panel1.Size = New System.Drawing.Size(444, 26)
        Me.panel1.TabIndex = 6
        '
        'buttonMin
        '
        Me.buttonMin.BackgroundImage = Global.Borderless_Form.My.Resources.Resources.minimize2
        Me.buttonMin.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
        Me.buttonMin.Location = New System.Drawing.Point(370, 3)
        Me.buttonMin.Name = "buttonMin"
        Me.buttonMin.Size = New System.Drawing.Size(20, 20)
        Me.buttonMin.TabIndex = 2
        Me.buttonMin.UseVisualStyleBackColor = True
        '
        'buttonClos
        '
        Me.buttonClos.BackgroundImage = Global.Borderless_Form.My.Resources.Resources.close2
        Me.buttonClos.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
        Me.buttonClos.Location = New System.Drawing.Point(422, 3)
        Me.buttonClos.Name = "buttonClos"
        Me.buttonClos.Size = New System.Drawing.Size(20, 20)
        Me.buttonClos.TabIndex = 0
        Me.buttonClos.UseVisualStyleBackColor = True
        '
        'buttonMax
        '
        Me.buttonMax.BackgroundImage = Global.Borderless_Form.My.Resources.Resources.maximize2
        Me.buttonMax.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
        Me.buttonMax.Location = New System.Drawing.Point(396, 3)
        Me.buttonMax.Name = "buttonMax"
        Me.buttonMax.Size = New System.Drawing.Size(20, 20)
        Me.buttonMax.TabIndex = 1
        Me.buttonMax.UseVisualStyleBackColor = True
        '
        'Timer1
        '
        Me.Timer1.Enabled = True
        Me.Timer1.Interval = 50
        '
        'Borderless
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(449, 210)
        Me.Controls.Add(Me.panel1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Name = "Borderless"
        Me.Text = "Borderless Form"
        Me.panel1.ResumeLayout(False)
        Me.panel1.PerformLayout()
        Me.ResumeLayout(False)

    End Sub
    Private WithEvents labelName As System.Windows.Forms.Label
    Private WithEvents panel1 As System.Windows.Forms.Panel
    Private WithEvents buttonMin As System.Windows.Forms.Button
    Private WithEvents buttonClos As System.Windows.Forms.Button
    Private WithEvents buttonMax As System.Windows.Forms.Button
    Friend WithEvents Timer1 As System.Windows.Forms.Timer

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions