Application Bar Update - AutoHide

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
13 posts Page 1 of 2
User avatar
imbeta
Site Admin
Site Admin
Posts: 12
Joined: Thu Jul 23, 2009 4:21 pm

Application Bar Update - AutoHide
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
You do not have the required permissions to view the files attached to this post.
Im codenstuff.com...Im the moderator...iMBETA
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

Re: Application Bar Update - AutoHide
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
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

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;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

Re: Application Bar Update - AutoHide
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
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
User avatar
Ziro
Just Registered
Just Registered
Posts: 5
Joined: Tue Sep 08, 2009 5:46 am

Re: Application Bar Update - AutoHide
Ziro
W0w This is a really good program, I can't find an exe though..
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

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;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Neki
Top Poster
Top Poster
Posts: 96
Joined: Sun Oct 11, 2009 10:12 am

Re: Application Bar Update - AutoHide
Neki
Great job! I'm downloading it!
User avatar
Normall
Member
Member
Posts: 49
Joined: Wed Nov 25, 2009 9:25 pm

Nice!
User avatar
Normall
Member
Member
Posts: 49
Joined: Wed Nov 25, 2009 9:25 pm

Nice
User avatar
bfh13
Just Registered
Just Registered
Posts: 5
Joined: Fri Jun 04, 2010 8:27 am

Re: Application Bar Update - AutoHide
bfh13
it made my icons move left
13 posts Page 1 of 2
Return to “Tutorials”