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

Posted on 2007-08-10
Last Modified: 2013-12-03
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.
Question by:JackVannoy
    LVL 85

    Accepted Solution

    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...

    Author Comment

    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?



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now