• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 601
  • Last Modified:

How do I move a Sheridan Panel or Frame around on a Visual Basic 6 Form with the Mouse?

I have a visual basic project with multiple forms.  I want to be able to move a Sheridan panel or a Visual Basic panel around on a form by using the mouse.  Would appreciate any help on this.
0
JackVannoy
Asked:
JackVannoy
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Hi JackVannoy,

Your TITLE says "Visual Basic 6" but you are asking how to move a PANEL...and the question is cross-posted in VB.NET.

Which is it?  VB6 doesn't have a Panel!...    =\

To move a PictureBox in VB6:

    Option Explicit

    Private startX As Single
    Private startY As Single

    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            startX = X
            startY = Y
        End If
    End Sub

    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            Picture1.Move Picture1.Left + (X - startX), Picture1.Top + (Y - startY)
        End If
    End Sub


To move a Panel in VB.Net:

    Private startX, startY As Integer

    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
            startX = e.X
            startY = e.Y
        End If
    End Sub

    Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Panel1.Location = New Point(Panel1.Location.X + (e.X - startX), Panel1.Location.Y + (e.Y - startY))
        End If
    End Sub


I don't have any Sheridan controls but I imagine it would be done in a similar fashion if they expose equivalent properties and events...
0
 
JackVannoyAuthor Commented:
Hi Idle Mind

I am using Visual Basic 6, however I do have the license for the Sheridan controls which includes an SS Panel object

Thi first example (Moving a picture box) seems to work fine to move the frame around.  However, if I move to where the left edge of the frame is less than the left edge of the form the frame will disapear.  Same is true when the top of the frame less than the top of the form.

Can you help me with this?

Thanks

Jack
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now