Larsa

Does anybody knows how i can make my entire application hide when not used

and get visible when i point my mouse over the top end of the screen. (Not in the systray)

Or where i can read about it



Re: Visual Basic Express Edition Flyout application

Omar Abid

you can hide the form...

Form1.hide()

So the application still running but the form don't appear






Re: Visual Basic Express Edition Flyout application

Dave299

You need to decide what you mean by "your application is not being used". Assuming you mean something like: it has not received a keypress nor experienced any mouse movement for a certain period of time then something like the following could work for you.

Tmr2 determines the interval for which no activity has been detected. Whemever any activity is detected it is stopped and restarted. If there is no activity it ticks and the application hides. For demonstration purposes only the timer interval is set to 5 seconds.

Tmr1 checks the cursor position every 1/4 second and if it is near the top of the screen makes the application visible again if it has been hidden.

Public Class Form1

Dim WithEvents Tmr1 As New Timer

Dim WithEvents Tmr2 As New Timer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

KeyPreview = True

For Each C As Control In Me.Controls

AddHandler C.MouseMove, AddressOf RestartTimerOnMouseMovement

AddHandler C.KeyDown, AddressOf RestartTimerOnKey

Next

AddHandler Me.MouseMove, AddressOf RestartTimerOnMouseMovement

AddHandler Me.KeyDown, AddressOf RestartTimerOnKey

Tmr1.Interval = 250

Tmr2.Interval = 5000

Tmr2.Start()

End Sub

Private Sub Tmr1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tmr1.Tick

If Cursor.Position.Y < 5 Then

Me.Show()

Tmr2.Start()

Tmr1.Stop()

End If

End Sub

Private Sub RestartTimerOnMouseMovement(ByVal sender As Object, ByVal e As MouseEventArgs)

Tmr2.Stop()

Tmr2.Start()

End Sub

Private Sub RestartTimerOnKey(ByVal sender As Object, ByVal e As KeyEventArgs)

Tmr2.Stop()

Tmr2.Start()

End Sub

Private Sub Tmr2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tmr2.Tick

Me.Hide()

Tmr2.Stop()

Tmr1.Start()

End Sub

End Class





Re: Visual Basic Express Edition Flyout application

Larsa

Thanks Dave for your reply.

That was very helpful, it was exactly what i was looking for.

But is it really nessecery to use a timer to check the cursor position, or could i use some sort of interupt

Like " Whait until ..."

Best regards Lars-Ake





Re: Visual Basic Express Edition Flyout application

Dave299

Well........

You could use something like:

Private Sub Tmr2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tmr2.Tick

Me.Hide()

Tmr2.Stop()

Do While Cursor.Position.Y > 5

Threading.Thread.Sleep(1)

Loop

Me.Show()

Tmr2.Start()

End Sub

but I prefer to avoid Thread.Sleep. There was a long thread about this recently which is well worth reading.





Re: Visual Basic Express Edition Flyout application

Larsa

Thank you all for your help.