Imports System.Runtime.InteropServicesPublic Class Form1 Const WM_NCLBUTTONDOWN As Integer = &HA1 Const HT_CAPTION As Integer = &H2 <DllImport("user32.dll")> _ Public Shared Function SendMessage(hWnd As IntPtr, Msg As Integer, wParam As Integer, lParam As Integer) As Integer End Function <DllImport("user32.dll")> _ Public Shared Function ReleaseCapture() As Boolean End Function Private Sub OnMouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then ReleaseCapture() SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0) End If End SubEnd Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _Partial Class Form1 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.SuspendLayout() ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(284, 261) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End SubEnd Class
Form1.vb -
Open in new window
Form1.Designer.vb -Open in new window
-saige-