John Delmark Aguilar
Would you like to react to this message? Create an account in a few clicks or log in to continue.
John Delmark Aguilar

Personal Forum
 
HomeSearchLatest imagesRegisterLog in

 

 Drag Form without title bar

Go down 
AuthorMessage
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

Drag Form without title bar Empty
PostSubject: Drag Form without title bar   Drag Form without title bar Icon_minitimeThu 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
Back to top Go down
https://delmark.forumtl.com
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

Drag Form without title bar Empty
PostSubject: Re: Drag Form without title bar   Drag Form without title bar Icon_minitimeThu 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
Back to top Go down
https://delmark.forumtl.com
 
Drag Form without title bar
Back to top 
Page 1 of 1
 Similar topics
-
» [HTML+JS] Form Validation + Get Value
» [JS]Simple Javascript Form Alert

Permissions in this forum:You cannot reply to topics in this forum
John Delmark Aguilar :: dElmARk Productions :: VB.net Programs :: VB Tutorials | Tips and Tricks-
Jump to: