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()
        'This call is required by the Windows Form Designer. 
        '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)
        End If
    End Sub

End Class

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)
                m.Result = New IntPtr(HitTestResult.HTCLIENT)
            End If
        End If
    End Sub

End Module

Recommended Answers

Set FormBorderStyle

Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Jump to Post

All 2 Replies

Set FormBorderStyle

Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None

Set FormBorderStyle

Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None

I don't think he is talking about resizing it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.