Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 26th, 2006, 6:53 PM   #1
emdiesse
Programmer
 
Join Date: Jul 2004
Location: Hampshire
Posts: 56
Rep Power: 5 emdiesse is on a distinguished road
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
emdiesse is offline   Reply With Quote
Old Nov 1st, 2006, 12:02 AM   #2
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 237
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
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
melbolt is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Eternity Online Lucid Project Ideas 4 May 12th, 2005 9:54 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:28 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC