Application Bar Update - AutoHide
Posted: Sat Aug 01, 2009 8:58 pm
Hello Guys,
OK I have another update for you. This one is to have an Auto-Hide feature where the bar hides off screen when its inactive for 5 seconds and can be brought back on screen by moving your mouse over it.
Heres how to add it to the code. Its a good idea to first backup your original code just incase something goes wrong. Are you ready? ok lets start...
First things first. You need to add a 'Timer' control to the form and set the 'Interval' Property to what-ever you want, in this case ive set it to 5 seconds (5000).
Now you need to add a new menu to the 'ContextMenuStrip' so click on it then when the menu appears click on box which says "Type Here" and enter 'Auto Hide'. Once you have done that you need to set its 'CheckonClick' propertie to 'True' and thats all you need to do for that. Now comes the code part.
So find and add the following:
Find:
And that should be it. Congratulations you now have an Auto-Hide feature!. Compile > Save and Run your new Application Bar to see the results.
Download this update: If you have any problems let me know and I will help you.
Thank you and stay tuned for more updates in the future
OK I have another update for you. This one is to have an Auto-Hide feature where the bar hides off screen when its inactive for 5 seconds and can be brought back on screen by moving your mouse over it.
Heres how to add it to the code. Its a good idea to first backup your original code just incase something goes wrong. Are you ready? ok lets start...
First things first. You need to add a 'Timer' control to the form and set the 'Interval' Property to what-ever you want, in this case ive set it to 5 seconds (5000).
Now you need to add a new menu to the 'ContextMenuStrip' so click on it then when the menu appears click on box which says "Type Here" and enter 'Auto Hide'. Once you have done that you need to set its 'CheckonClick' propertie to 'True' and thats all you need to do for that. Now comes the code part.
So find and add the following:
Find:
Code: Select all
Underneath it Add:
Public Class Form1
Public rowz = 20
Public horv
Code: Select all
Find:
Public hider = 0
Code: Select all
Just before 'End Sub' add 'hider = 1' So it looks like this:Private Sub Lab_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs)
CType(sender, PictureBox).Size = New Size(40, 40)
If horv = "top" Then
CType(sender, PictureBox).Location = New Point(sender.Location.X - 5, sender.Location.Y)
ElseIf horv = "bottom" Then
CType(sender, PictureBox).Location = New Point(sender.Location.X - 5, sender.Location.Y)
ElseIf horv = "right" Then
CType(sender, PictureBox).Location = New Point(sender.Location.X - 5, sender.Location.Y)
Else
CType(sender, PictureBox).Location = New Point(sender.Location.X + 5, sender.Location.Y)
End If
End Sub
Code: Select all
Now head right down to the very last line of your code and just above 'End Class' add this new code:Private Sub Lab_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs)
CType(sender, PictureBox).Size = New Size(40, 40)
If horv = "top" Then
CType(sender, PictureBox).Location = New Point(sender.Location.X - 5, sender.Location.Y)
ElseIf horv = "bottom" Then
CType(sender, PictureBox).Location = New Point(sender.Location.X - 5, sender.Location.Y)
ElseIf horv = "right" Then
CType(sender, PictureBox).Location = New Point(sender.Location.X - 5, sender.Location.Y)
Else
CType(sender, PictureBox).Location = New Point(sender.Location.X + 5, sender.Location.Y)
End If
hider = 1
End Sub
Code: Select all
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If AutoHideToolStripMenuItem.Checked = True Then
If horv = "top" And hider = 0 Then
Me.Top = Screen.PrimaryScreen.Bounds.X - 49
hider = 1
End If
If horv = "left" And hider = 0 Then
Me.Left = Screen.PrimaryScreen.Bounds.Y - 43
hider = 1
End If
If horv = "right" And hider = 0 Then
Me.Left = Screen.PrimaryScreen.Bounds.Width - Me.Width + 43
hider = 1
End If
If horv = "bottom" And hider = 0 Then
Me.Top = Screen.PrimaryScreen.WorkingArea.Height - Me.Height + 48
hider = 1
End If
End If
Timer1.Enabled = False
End Sub
Private Sub Form1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseEnter
If horv = "top" And hider = 1 Then
Timer1.Enabled = False
Me.Top = Screen.PrimaryScreen.Bounds.X
End If
If horv = "left" And hider = 1 Then
Timer1.Enabled = False
Me.Left = Screen.PrimaryScreen.Bounds.Y
End If
If horv = "right" And hider = 1 Then
Timer1.Enabled = False
Me.Left = Screen.PrimaryScreen.Bounds.Width - Me.Width
End If
If horv = "bottom" And hider = 1 Then
Timer1.Enabled = False
Me.Top = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
End If
hider = 1
End Sub
Private Sub Form1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.MouseLeave
hider = 0
Timer1.Enabled = True
End Sub
Private Sub AutoHideToolStripMenuItem_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AutoHideToolStripMenuItem.CheckedChanged
If AutoHideToolStripMenuItem.Checked = False Then
Me.TopMost = False
Else
Me.TopMost = True
End If
End Sub
And that should be it. Congratulations you now have an Auto-Hide feature!. Compile > Save and Run your new Application Bar to see the results.
Download this update: If you have any problems let me know and I will help you.
Thank you and stay tuned for more updates in the future
