dElmARk Admin
Posts : 92 Join date : 09/04/2012
| Subject: Drag Form without title bar Thu Apr 18, 2013 1:08 pm | |
| - Code:
-
Dim newPoint As New System.Drawing.Point() Dim a As Integer Dim b As Integer Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown a = Me.MousePosition.X - Me.Location.X b = Me.MousePosition.Y - Me.Location.Y End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove If e.Button = MouseButtons.Left Then newPoint = Me.MousePosition newPoint.X = newPoint.X - (a) newPoint.Y = newPoint.Y - (b) Me.Location = newPoint End If
| |
|
dElmARk Admin
Posts : 92 Join date : 09/04/2012
| Subject: Re: Drag Form without title bar Thu Apr 18, 2013 1:16 pm | |
| Another one: - Code:
-
#Region " ClientAreaMove Handling " Const WM_NCHITTEST As Integer = &H84 Const HTCLIENT As Integer = &H1 Const HTCAPTION As Integer = &H2 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Select Case m.Msg Case WM_NCHITTEST MyBase.WndProc(m) If m.Result = HTCLIENT Then m.Result = HTCAPTION 'If m.Result.ToInt32 = HTCLIENT Then m.Result = IntPtr.op_Explicit(HTCAPTION) 'Try this in VS.NET 2002/2003 if the latter line of code doesn't do it... thx to Suhas for the tip. Case Else 'Make sure you pass unhandled messages back to the default message handler. MyBase.WndProc(m) End Select End Sub #End Region
| |
|