Results 1 to 40 of 40

Thread: Move and Resize a Control or a Borderless Form - using window messages (smooth!)

Threaded View

  1. #40
    Fanatic Member
    Join Date
    Nov 2016
    Location
    Slovenia
    Posts
    575

    Re: Move and Resize a Control or a Borderless Form - using window messages (smooth!)

    Hi guys, me again

    I took a liberty and slightly modified original code. There may be someone else who needs this in plenty borderless forms (like me) so I moved all into module to shorten things out under form's code. This way you can handle each form like this:

    Code:
      Private Sub pnlCaption_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlCaption.MouseDown
            If e.Button = Windows.Forms.MouseButtons.Left And Me.WindowState <> FormWindowState.Maximized Then
                MoveForm(Me)
            End If
        End Sub
    
        Private Sub pnlCaption_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlCaption.MouseMove
            If Me.WindowState = FormWindowState.Maximized Then Return
            SetDirection(Me)
        End Sub
    
        Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
            If e.Button = Windows.Forms.MouseButtons.Left And Me.WindowState <> FormWindowState.Maximized Then
                ResizeForm(Me, resizeDir(Me)) 'allow form resize and moving.
            End If
        End Sub
    
        Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
            If Me.WindowState = FormWindowState.Maximized Then Return
            SetDirection(Me)
        End Sub
    Sample is attached. I hope you don't mind NickThissen, and thanks again for sharing such a nice solution !!
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width