As u all know,at runtime we can move the form.
I use the foll. code,so dat form doesn't move.I want to ask dat is there any easy way to do it.
Mine code below working correctly,but lengthy-
Option Compare Text
Option Strict On
Option Explicit On
Public Class Form1
Dim RCTransparentVerticalBar As Rectangle
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Make the fake caption rectangle
RCTransparentVerticalBar = New Rectangle(0, 0, Me.Width, 29)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
'We want to pretend that the rectangle RCTransparentVerticalBar, is the caption bar so we can drag the form by it...
If m.Msg = WM_NCHITTEST Then
Call FakeCaptionForCaptionlessWindow(Me, m, RCTransparentVerticalBar)
Else
MyBase.WndProc(m)
End If
End Sub
End Class
ADD MODULE
Option Strict On
Option Explicit On
Option Compare Text
Module ModMoveForm
Public Const WM_NCHITTEST As Long = &H84
Public Enum HitTestResult
HTBORDER = 18
HTBOTTOM = 15
HTBOTTOMLEFT = 16
HTBOTTOMRIGHT = 17
HTCAPTION = 2
HTCLIENT = 1
HTERROR = (-2)
HTGROWBOX = 4
HTHSCROLL = 6
HTLEFT = 10
HTMAXBUTTON = 9
HTMENU = 5
HTMINBUTTON = 8
HTNOWHERE = 0
HTRIGHT = 11
HTSYSMENU = 3
HTTOP = 12
HTTOPLEFT = 13
HTTOPRIGHT = 14
HTVSCROLL = 7
HTTRANSPARENT = (-1)
HTOBJECT = 19
HTCLOSE = 20
HTHELP = 21
End Enum
Public Sub FakeCaptionForCaptionlessWindow(ByVal fParent As Form, ByRef m As Message, ByVal CaptionRectangle As Rectangle)
If m.Msg = WM_NCHITTEST Then
'\\ If the mouse is in the rectangle that is considered to be the caption set the return value to HTCAPTION
Dim ptClickLocation As New Point(m.LParam.ToInt32)
ptClickLocation = fParent.PointToClient(ptClickLocation)
If CaptionRectangle.Contains(ptClickLocation) Then
m.Result = New IntPtr(HitTestResult.HTCAPTION)
Else
m.Result = New IntPtr(HitTestResult.HTCLIENT)
End If
End If
End Sub
End Module