Click here to Skip to main content
15,893,508 members
Articles / Programming Languages / Visual Basic
Tip/Trick

Programming Thumbnail ToolBar Buttons in VB.NET

Rate me:
Please Sign up or sign in to vote.
4.82/5 (3 votes)
30 Sep 2015CPOL2 min read 15K   3   3
You will learn all the steps for programming a Thumbnail Toolbar with buttons.

Introduction

All articles for this topic I found weren't clear enough to resume in code. This tip describes all steps to arrive at a code solution.

Background

I found this, this and this very useful.

Using the Code

The code shows how to initialize a thumbnail toolbar with 4 buttons. You must apply changes to your code keeping in mind that this code must be pasted in the form_load event as the first thing to be executed before the form is shown.

But previously, you must install some extension to your compiler. In particular, I'm using VS2010 in Spanish, so I'm sorry if names in English are not accurate.

Step 1

First, you must install the Package Manager. Open VS with the solution you like to use with thumbnail Toolbar buttons, go to Tools Menu, Extensions Administrator. Select All or Gallery and select NuGet Package Manager - Install. Close VS and reopened it.

In tools, now you will find NuGet Package Administrator -> Package Administrator Console. After running some commands will stop in the symbol prompt PM>

Step 2

You must run three commands:

PM> Install-Package WindowsAPICodePack

PM> Install-Package Microsoft.WindowsAPICodePack.shell

PM> Install-Package Microsoft.WindowsAPICodePack.core

You are now ready to use the taskbar by referencing it.

Step 3

You must add to your resources four icons. For the examples, I named Master, Truck, Card and Safety. Be sure the location is Icons, not Images, and the extension is .ico.

Step 4

This code creates four buttons with icons in the thumbnail taskbar for your program.

VB.NET
Imports Microsoft.WindowsAPICodePack.Taskbar

Public Class Form1

    Private WithEvents button1 As ThumbnailToolBarButton
    Private WithEvents button2 As ThumbnailToolBarButton
    Private WithEvents button3 As ThumbnailToolBarButton
    Private WithEvents button4 As ThumbnailToolBarButton

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

        button1 = New ThumbnailToolBarButton(My.Resources.Master, "Clients")
        button2 = New ThumbnailToolBarButton(My.Resources.Truck, "Suppliers")
        button3 = New ThumbnailToolBarButton(My.Resources.Card, "Materials")
        button4 = New ThumbnailToolBarButton(My.Resources.Safety, "Founds")

        TaskbarManager.Instance.ThumbnailToolBars.AddButtons_
		(Me.Handle, button1, button2, button3, button4)

        'Your load event code begins here...

    End Sub

    Private Sub button1_Click(sender As System.Object, e As ThumbnailButtonClickedEventArgs) _
		Handles button1.Click
        Form2.Show()    'or whatever you need to be executed
    End Sub

    Private Sub button2_Click(sender As System.Object, e As ThumbnailButtonClickedEventArgs) _
		Handles button2.Click
        Form3.Show()    'or whatever you need to be executed
    End Sub

    Private Sub button3_Click(sender As System.Object, e As ThumbnailButtonClickedEventArgs) _
		Handles button3.Click
        Form4.Show()    'or whatever you need to be executed
    End Sub

    Private Sub button4_Click(sender As System.Object, e As ThumbnailButtonClickedEventArgs) _
		Handles button4.Click
        Form5.Show()    'or what ever you need to be executed
    End Sub

End Class

The maximum number of buttons is seven.

Points of Interest

After two days of learning about this topic, I resume it in a couple of lines of code. As a programmer, I think it is more useful to have a few lines of code instead of a lot of pages with explanations.

My next step is to code a Jump List.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
AnswerErrors in VS 17' How to fix! Pin
Jeffrey Crowder4-Nov-17 15:11
Jeffrey Crowder4-Nov-17 15:11 
QuestionDid not work in VS 2015, ask for a reference Pin
Ger F.10-Oct-15 0:03
Ger F.10-Oct-15 0:03 
Hello Alberto,

I did exactly you said. The only diverence I use VS 2015 express.

When I build the program there comes an error:

Error BC30652 Reference required to assembly 'PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' containing the type 'UIElement'. Add one to your project.

What can I do?

Best regards Ger F.
AnswerRe: Did not work in VS 2015, ask for a reference Pin
Ing. Alberto Tognacca20-Oct-15 5:56
professionalIng. Alberto Tognacca20-Oct-15 5:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.