Notice in the image behind the explorer icon, there is a green progress bar, which is a clone of the actual one. Today we will make one of these for our own programs.
First of all, you will need the Windows API to even think about using such features of windows 7. you can download it free Here
Once you have that, we can start coding!
Open up Visual Studio and create a new project. we will call ours taskbarProgress.
In order to use our new API, we need to tell VS where it is. Do this by:
going to the my project page
clicking the refrences tab
clicking on the browse tab
locating Microsoft.WindowsAPICodePack.Shell.dll (should be in WindowsAPICodePack\Shell\bin\Debug\ from where you extracted the API)
Now we design the form. Mine will be very simple:
Just a Trackbar and a Progressbar. I also changed the title, made the form un-resisable and disabled the maximise button, but none of that's important.
Now for coding. Double click the trackbar to create a Trackbar_Scroll Event.
At the top you will need to add this code:
Imports Microsoft.WindowsAPICodePack Imports Microsoft.WindowsAPICodePack.Taskbar
so we can use the API
in the Trackbar_Scroll Event add the folowing code:
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll ProgressBar1.Value = TrackBar1.Value * 10 End Sub
all this does is update the progress bar to follow the trackbar.
Now we will update our little progressbar clone on the taskbar to match the real progressbar.
We will add this to the TrackBar1_Scroll event.
TaskbarManager.Instance.SetProgressValue(TrackBar1.Value * 10, 100)
And that's it. Easy, huh? this simply sets the value of the taskbar mini-progressbar.
8 lines of code and were done.
Because it's so simple, it's easy to integrate into all of your projects. but don't stop here. the windows API opens a whole new... Window of opportunities for you to make you program much better. I hope I make you realise what you can do with this API
Thank you for reading my tutorial! I hope it was helpful! leave a comment on what you thought and where I could Improve! Thanks again!!
Imports Microsoft.WindowsAPICodePack Imports Microsoft.WindowsAPICodePack.Taskbar Public Class Form1 Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll ProgressBar1.Value = TrackBar1.Value * 10 TaskbarManager.Instance.SetProgressValue(TrackBar1.Value * 10, 100) End Sub End Class