2 Replies - 710 Views - Last Post: 07 November 2012 - 12:54 PM Rate Topic: -----

#1 DoxramosPS  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 171
  • Joined: 07-October 12

Moving a borderless form.

Posted 07 November 2012 - 12:48 PM

Right Now I have
Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Capture = True
        End If
    End Sub


    Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp
        Capture = False
    End Sub


To Drag a form without a border. The Panel1 is at the top of my imagebox with my design template. The form however does not move if anyone would know why that would be great. Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Moving a borderless form.

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1052
  • View blog
  • Posts: 4,077
  • Joined: 02-July 08

Re: Moving a borderless form.

Posted 07 November 2012 - 12:52 PM

Yes, you are not changing the Location coordinates of the form in MouseMove event. Tutorial!

This post has been edited by _HAWK_: 07 November 2012 - 12:52 PM

Was This Post Helpful? 0
  • +
  • -

#3 rusoaica  Icon User is offline

  • D.I.C Head

Reputation: 42
  • View blog
  • Posts: 211
  • Joined: 10-March 12

Re: Moving a borderless form.

Posted 07 November 2012 - 12:54 PM

try it this way:

    Private IsFormBeingDragged As Boolean
    Private MouseDownX As Integer
    Private MouseDownY As Integer
    

    Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
        If e.Button = MouseButtons.Left Then
            IsFormBeingDragged = True
            MouseDownX = e.X
            MouseDownY = e.Y
        End If
    End Sub

    Private Sub Button1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove
        If IsFormBeingDragged Then
            Dim temp As Point = New Point()
            temp.X = Me.Location.X + (e.X - MouseDownX)
            temp.Y = Me.Location.Y + (e.Y - MouseDownY)
            Me.Location = temp
            temp = Nothing
        End If
    End Sub

    Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp
        If e.Button = MouseButtons.Left Then
            IsFormBeingDragged = False
        End If
    End Sub




Was This Post Helpful? 0
  • +
  • -

Page 1 of 1