Tuesday, 2 October 2012

How to Move form by an object without title bar

Make Declaration as follow:

Private Declare Sub ReleaseCapture Lib "user32" ()
    Private Declare Sub SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer)
    Private Const WM_NCLBUTTONDOWN As Integer = &HA1
    Private Const HTCAPTION As Integer = 2

Place the following code under “MouseDown” Event of an object

If eb.Button = Windows.Forms.MouseButtons.Left Then
            SendMessage(frm.Handle.ToInt32, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If

No comments:

Post a Comment