MDI TaskBar

This is an UserControl transferring concept of Windows 95 TaskBar to MDI application. When located inside MDI window, it will group icons for all MDI child windows and allow user to select one by pressing respective button. Also context menu for an icon and for whole toolbar is supported, but has to be provided by MDI parental window in event handlers.
"Auto hide" feature is not implemented yet.

Files

Source code is provided with a sample (MDI application generated by VB Application Wizard). Actual code (which should be ported to your application) is in following files:

  • TaskBar.ctl  - UserControl code
  • Icon.cls - a class used for storing information about child windows handled
  • Declares.bas - contains all necessary API related stuff.

Components

As it was written, there are two major components: a control itself and an auxiliary class clsIcon. The TaskBar control uses some functions from API, declared in moduleDeclares and some module routines implemented there.

UserControl TaskBar

The idea is simple. User control located inside MDI parental window receives notifications about all changes in status of any MDI child window (e.g. change in state, destroying, creating, activating and deactivating), and, when notified, scans Forms collection for all windows with proper attributes (MDIChild & ShowInTaskbar). In order to receive these notifications, MDIClient window has to be subclassed (described in Declares section).

For each control an object of the clsIcon class is created and stored internally in the collection m_colIcons. All important changes (e.g. these, we carry about) to each window made by an user are thus reflected in the collection. Then the collection will be used (in UserControl_Paint event handler) to prepare buttons for each window.

There are no other controls placed on TaskBar control. Everything is painted "by hand" and all events (mouse up, down etc.) are handled by a code of the control. When an user clicks within control, program determines, which button is affected and then changes it's state (and look). I think, I implemented reasonable behavior. When a change made by user to a window affect only one button, only a part of the toolbar will be repainted (I use API InvalidateRect instead of VB's Refresh).

Operations of minimizing and restoring MDI windows are handled separately in order to achieve effect of "hiding" windows.

Class clsIcon

Class clsIcon stores all information necessary to paint a button for a specific window, including a reference to window's icon. It also has a feature (touch properties), which helps me to detect, which window has ben destroyed and is no longer present without performing separate iteration through Forms and icons collections to compare them.

Module Declares

The module contains all global API declares required and implementation of two crucial functions:

  • the one, which subclasses MDIClient window
  • new WndProc for MDIClient, which notifies UserControl about events among MDI Client children

How to Use That

Simply append these three files to your project and place TaskBar on your MDI Form. If you want to have context menu for taskbar and for child windows (right click on a button), you have to provide proper menu objects in handlers for events fired by this control.

Limitations

  • MDI TaskBar, as it is implemented can't exist as a separate ActiveX - the reason is it uses the Forms collection.
  • You can't place additional buttons on the toolbar unless you will change all calculation related functions (ItemRect etc.).
  • Although TaskBar may be docked vertically, it won't work properly if there are to many windows (it won't crash, but new windows won't be displayed).
  • This cool "Auto hide" feature is not implemented yet.

Download project file



Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Businesses are moving more and more of their customer transactions to the web. Security is understandably a top concern as online transactions increase, so it is important to make sure your electronic signature provider meets the highest security standards. That means more than simply passing a security audit or obtaining a certification. This white paper provides recommendations for taking a broader view of e-signature security, and answers key questions that help identify the security requirements against …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds