Link to home
Start Free TrialLog in
Avatar of narmi2
narmi2

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"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.