Blue Theme Orange Theme Green Theme Red Theme
 
Discover the top 5 tips for understanding .NET Interop
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Nevron Chart
Search :       Advanced Search »
Home » Windows Forms C# » Enhanced TaskBar in VS 2005 using C# and Windows Forms

Enhanced TaskBar in VS 2005 using C# and Windows Forms

This article shows how to add additional features which are not available in Windows Taskbar.

Author Rank :
Page Views : 12191
Downloads : 603
Rating :
 Rate it
Level : Intermediate
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
EnhancedTaskBarExplorer.zip
 
 
Team Foundation Server Hosting
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

For most us, Windows's Taskbar is common one used to switch between applications. But, Windows's Taskbar will make our work of switching little bit hard.

It won't support enhanced iconic view of an application, easy navigation and screenshot capturing etc. I think it's better to design an application that will make switching among applications little bit easier. So, I design this application in VS.NET 2005 using C# and windows forms. I will explain features provided by this application followed by its design and coding.

Features present in this application:

  • It provides enhanced iconic view of active application, which gets updated automatically. 
  • It provides clear view of the running applications.
  • It allows us to take screenshot of required application.
  • It allows us to close the application.
  • It allows us to switch between applications easily.

Now, create a new Windows Application using C# in VS.NET 2005 and name it as EnhancedTaskBarExplorer. Add controls to Main Form (TaskBar) as shown below:

I placed a ContextMenu and NotifyIcon control on the form. Contextmenu is assigned to TaskBar Item (for button displayed on the form for each TaskBar item) and NotifyIcon is assigned to Main Form for controlling visibility of the application.

Following are the menuitems present in Contextmenu (TaskBarContextMenu control, assigned to TaskBar item (Button)):

  • Close --> It is used to kill selected application.
  • Save Screenshot --> It is used to store the screenshot of the application.
  • Save Updated Screenshot --> It is used to store the screenshot of the current application.
  • Enter File Name Textbox --> It is used to set the filename of the application's screenshot to be stored.
  • Clear All --> It is used to clear all TaskBar Items.

The main functionality of this application is it will create a button with a screenshot of the application as an image on it in main form whenever a new application (Window) is activated and monitors for active window change by using System.Threading.Timer object.

Now, I will explain coding part of this application. I added three class files to the application. I will outline functionality of each class.

TItems.cs is used to handle the properties of a window like Window Handle, Window title, Process ID, Screenshot of the Window etc.

Functionality present in TaskBarItems.cs:

In order to create buttons for each taskbar item, I implemented concept of control array of VB here. Here, I just created a class named TaskBarItems which inherits from System.Collections.CollectionBase and in constructor of this class, I am passing container (Main Form) for this buttons. Than I added three methods to implement add new button (taskbar item), to remove selected taskbar item, to remove all taskbar items from application.

In AddnewTaskBarItem(), I created a new button having following properties:

Name --> WindowHandle of the Application.
Image --> Screenshot of the active Window.

And also some other properties like width, height and onclick event handler etc.

Functionality present in APIFuncs.cs:

In this class, I am using Windows API methods to get active window's screenshot. Actually, I am getting Handle of the active window using GetForegroundWindow() and than that handle is passed to GetWindowProcessID() to get Process ID. Than, this process id is passed to GetProcessById() for getting process. Finally, I am taking screenshot of the active window and created an instance of TItems class with above values added to the TItems's properties. This TItems object will be added to generic list [MyTaskBarItems] for later use.

Functionality present in TaskBar.cs:

Here, we are creating an instance of timer, which will call GetAndDisplayTaskBarData() method and performs following things:

Step 1: It will get active window's title, Handle, process ID etc.

Step 2: Than, it will check whether that window handle is present or not in MyTaskBarItems list.If it doesn't exist,than it is a new window which is not having screenshot of it in the Form.So,it will add it to the Form with a screenshot of it.If that window handle already exists,than it will just finds that handle (button having name as that window handle) and updates its Image property with current screenshot.By this, we can see updation in active window immediately in this Taskbar Form.

Finally, some code is added to save screenshot to a file, close selected application, enhance UI etc. And, the final output will be like this:

We can still enhance this application by improving UI, adding extra functionality like using more WIN32 functions instead of timers etc.

By using this application, we can easily access running applications with a better view on it. I am attaching source code for further reference. I hope this code will be useful for all.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Sateesh Arveti
I hold Bachelors degree in Computer Science along with MCSD,MCTS and MVP for the year 2009. Areas of Interest: C#, WPF, WF, silverlight, ASP.NET, Oracle and SQL Server.

Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Nevron Chart
Become a Sponsor
 Comments
ohhhhhhhhhhhh thanks by maisa On October 19, 2008
thanks alot
Reply | Email | Modify 
Doesn't work for games by Andrew On February 5, 2010
Looks greet, but doesn't work for some games (for example LineAge2)

Reply | Email | Modify 
EnhancedTaskBarExplorer by Gayathri On October 17, 2011
HOW CAN I INTEGRATE THIS APPLICATION IN ANOTHER WINDOWS APPLICATION.WHEN I ADDED THIS FORM INTO MY APPLICATION ONE EEROR OCCURED(Object reference not set to an instance of an object.).PLEASE GIVE ME A SOLUTION.
Reply | Email | Modify 
Timer by Gayathri On October 20, 2011
hi how can i set a timer in this active window????I want to calculate the time that howmuch time the active window is opened....
Reply | Email | Modify 

 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.