![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jul 2004
Location: Hampshire
Posts: 56
Rep Power: 5
![]() |
Ha! It slides into eternity!
I have a context menu on my tray icon with the words show and hide depending upon where the form is it will either show or hide the form by sliding it by the system tray.
Below is code I have so far it didn't work but I made an attempt. It just slides and never stops I believe. How do I accomplish this task. Thank you Dim workingArea As Rectangle = Screen.PrimaryScreen.WorkingArea
Dim LocationTop, LocationBottom As Point
Dim FormShown As Boolean
Dim VerticalLocation, i As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
VerticalLocation = Me.Height
LocationTop = New Point(workingArea.Width - Me.Width, workingArea.Height - Me.Height)
LocationBottom = New Point(workingArea.Width - Me.Width, workingArea.Height)
Me.Location = LocationTop
FormShown = True
MenuItem1.Text = "Hide"
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
If FormShown = True Then
SlideTimer.Start()
Do While i <= 64
VerticalLocation = VerticalLocation - 2
Me.Location = New Point(workingArea.Width - Me.Width, workingArea.Height - VerticalLocation)
Loop
FormShown = False
Me.Hide()
MenuItem1.Text = "Show"
Else
Me.Show()
SlideTimer.Start()
Do While i <= 64
VerticalLocation = VerticalLocation + 2
Me.Location = New Point(workingArea.Width - Me.Width, workingArea.Height - VerticalLocation)
Loop
Me.Location = LocationTop
FormShown = True
MenuItem1.Text = "Hide"
End If
End Sub
Private Sub SlideTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SlideTimer.Tick
i = 0
Do While i < 64
i = i + 1
Loop
SlideTimer.Stop()
End Sub |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
here is what's happening, you fire off your timer, instantly the value of i reaches 64 in the timer tick handler. after that completes it continues on the following line where you have a "<=" the equals part of this is satisfied because the value is 64. since you never increment anymore at this point you have what is known as a "forever loop" and it just keeps right on going lol.
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Eternity Online | Lucid | Project Ideas | 4 | May 12th, 2005 9:54 AM |