troubleshooting Question

Help with my sliding panel

Avatar of narmi2
narmi2 asked on
Visual Basic.NET
2 Comments1 Solution693 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Mike Tomlinson
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros