Jump to content

Mover Form SemBorda


GnGs

Recommended Posts

#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

Resolvido

Link to comment
Share on other sites

Mais fácil ainda

Public Class Form1
    Private XI As Integer
    Private YI As Integer

    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        XI = e.X
        YI = e.Y
    End Sub

    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Me.Top = MousePosition.Y - YI
            Me.Left = MousePosition.X - XI
        End If
    End Sub
End Class

Marca como resolvido como deve de ser.

Não é à toa que mais ninguém tem tag "[resolvido]".

Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.