Help with my sliding panel

Hi

I'm working on a stripped down version of the sliding panels you see in vs.net's ide.  All my one does is it slides in or our depending on the mouse position, has a pin which stops in from sliding back in, and has a 0.5 second delay before it slides out and a 1 second delay before it slides back to it original position.

Here is the code................................

Option Strict On

Imports System.Threading

Public Class Form1
    Inherits System.Windows.Forms.Form

    Dim boolFlag As Boolean
    Dim DelayThread As Thread

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If boolFlag = True Then
            If pnlColumns.Width < 200 Then
                pnlColumns.Width += 20
            Else
                Timer1.Enabled = False
            End If
        Else
            If pnlColumns.Width > 0 Then
                pnlColumns.Width -= 20
            Else
                Timer1.Enabled = False
            End If
        End If
    End Sub

    Private Sub pnlLeft_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlLeft.MouseEnter
        DelayThread.Sleep(500)

        boolFlag = True
        Timer1.Enabled = True
    End Sub

    Private Sub pnlLeft_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlMain.MouseEnter
        If cbPin.Checked = False Then
            DelayThread.Sleep(1000)

            boolFlag = False
            Timer1.Enabled = True
        End If
    End Sub
End Class

................................

The problem is that the whole application freezes when I use the threading delay!  How do I add a delay without making it freeze?  Also is there a better way of doing this sliding panel thing?  A more optimised way?

Thanks
LVL 1
narmi2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
Simplest solution is to add another Timer (Timer2) to your Form:

    Private Sub pnlLeft_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlLeft.MouseEnter
        boolFlag = True
        Timer2.Stop()
        Timer2.Interval = 500
        Timer2.Start()
    End Sub

    Private Sub pnlLeft_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlMain.MouseEnter
        If cbPin.Checked = False Then
            boolFlag = False
            Timer2.Stop()
            Timer2.Interval = 1000
            Timer2.Start()
        End If
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Timer2.Stop()
        Timer1.Start()
    End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
"Also is there a better way of doing this sliding panel thing?  A more optimised way?"

I think we would need more information about the layout of your Form.  It's hard to tell exactly what is going on from just the code you gave.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.