Results 1 to 4 of 4

Thread: Dragging a form with no border?

  1. #1

    Thread Starter
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200

    Dragging a form with no border?

    O.K it is easy to drag a form with a border you just click the border and move the form....But how do you do it when a form has no border? I have made a form with a skin and no border so if i want to drag the form how can i do it....what if i have a picture box with an image on it that says click to drag...how can i use that to drag the form around....how can i move the form period without a border? Thanks

  2. #2
    Member
    Join Date
    Jul 2002
    Posts
    49
    Its a bit rough but it should give you the basic idea.

    Dim x, y As Integer

    Private Sub Form2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
    If e.Button = MouseButtons.Left Then
    Me.Location = New Drawing.Point(Me.Location.X - x + e.X(), Me.Location.Y - y + e.Y)
    End If
    End Sub

    Private Sub Form2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
    If e.Button = MouseButtons.Left Then
    x = e.X
    y = e.Y
    End If
    End Sub

  3. #3

    Thread Starter
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200
    another question!!

    O.K. i have the form,no border,but i have images around the form making my own personal borders

    how to stretch or shring the form from each side of the form

    left
    right
    and bottom

    say the left image is pic1
    the right image is pic2
    and the bottom image is pic3

    how could i click on them and have the same effect as if you were to have a border and click on one of the sides and drag them? thanks a ton!!!

  4. #4
    Member
    Join Date
    Jul 2002
    Posts
    49
    Set the three pictureboxes to be docked to whichever side they will be on, then set the cursor property to be SizeNS or SizeWE as needed and then just use this code.

    Dim x, y As Integer

    Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
    x = e.X
    End Sub

    Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
    If e.Button = MouseButtons.Left Then
    Me.Left += e.X - x
    Me.Width -= e.X - x
    End If
    End Sub

    Private Sub PictureBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseDown
    x = e.X
    End Sub

    Private Sub PictureBox2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove
    If e.Button = MouseButtons.Left Then
    Me.Width += e.X - x
    End If
    End Sub

    Private Sub PictureBox3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox3.MouseDown
    y = e.Y
    End Sub

    Private Sub PictureBox3_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox3.MouseMove
    If e.Button = MouseButtons.Left Then
    Me.Height += e.Y - y
    End If
    End Sub

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