Page 1 of 2

Application Bar Update - AutoHide

Posted: Sat Aug 01, 2009 8:58 pm
by imbeta
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:
Code: Select all
Public Class Form1
    Public rowz = 20
    Public horv
    
Underneath it Add:
Code: Select all
Public hider = 0
Find:
Code: Select all
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
Just before 'End Sub' add 'hider = 1' So it looks like this:
Code: Select all
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
Now head right down to the very last line of your code and just above 'End Class' add this new code:
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:
AppBarAutoHide.zip
If you have any problems let me know and I will help you.

Thank you and stay tuned for more updates in the future :D

Re: Application Bar Update - AutoHide

Posted: Fri Sep 04, 2009 3:13 pm
by Robby
Ty for the update i m going to download this and try it out as it looks insteresting

In this are there themes you can make btw?


Like i make a theme on paint or something and then can i use it on this

please reply back and tell me

Re: Application Bar Update - AutoHide

Posted: Fri Sep 04, 2009 3:29 pm
by CodenStuff
Hello,

It does have a theme option within the application but it is only for changing the background image of the bar but you can create your own image and use it within the application cooll;

Re: Application Bar Update - AutoHide

Posted: Fri Sep 04, 2009 6:16 pm
by Robby
o ok is it a different code for to do that or its a simple button in there please rep back i didn;t still see it so i dont know


Robby1998

Re: Application Bar Update - AutoHide

Posted: Tue Sep 08, 2009 6:18 am
by Ziro
W0w This is a really good program, I can't find an exe though..

Re: Application Bar Update - AutoHide

Posted: Tue Sep 08, 2009 12:17 pm
by CodenStuff
Ziro wrote:
W0w This is a really good program, I can't find an exe though..
Hello,

If you are unable to compile this project you can use the pre-built .exe file if you open up the bin > debug folder in the download cooll;

Re: Application Bar Update - AutoHide

Posted: Sun Oct 11, 2009 1:00 pm
by Neki
Great job! I'm downloading it!

Re: Application Bar Update - AutoHide

Posted: Wed Nov 25, 2009 10:14 pm
by Normall
Nice!

Re: Application Bar Update - AutoHide

Posted: Wed Nov 25, 2009 10:14 pm
by Normall
Nice

Re: Application Bar Update - AutoHide

Posted: Fri Jun 04, 2010 6:41 pm
by bfh13
it made my icons move left