• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 595
  • 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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

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