Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Programming Thumbnail ToolBar Buttons in VB.NET

0.00/5 (No votes)
30 Sep 2015 1  
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.

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here