Click here to Skip to main content
15,867,833 members
Articles / Desktop Programming / WTL
Article

An ATL Toolbox control like that of VS.NET 2003

Rate me:
Please Sign up or sign in to vote.
4.66/5 (8 votes)
4 Oct 2005CPOL3 min read 47.8K   2.9K   39   2
An ATL toolbox control.

Image 1

Introduction

This article presents a Toolbox control similar to the one used in Visual Studio .NET 2003. The main target was to achieve maximum similarity with the VS.NET Toolbox object model and GUI behaviour. It is written as an ATL ActiveX control using WTL 7.5 and STL and ATL collections.

Overview

Because I couldn't find such a control on the Internet, I decided write it myself. In the beginning, I had to fight with the GUI, but when I found a great article MS Access Bar written by Bjarke Viksoe, the fight was done.

I do not have much time to completely describe each and every method of all interfaces, but I'll give you a short overview. This version of the Toolbox contains some bugs that I have not fixed (moving tabs by selecting Move up/down from popup menu... try and you will find them) and the work is not finished yet, because of lack of time - but I am working on it.

Implementation

The Toolbox is a classic full ATL control. For my requirements I had to extend Bjarke Viksoe's MS Access Bar control (I have changed the code for drawing tabs and have added some helper methods).

The Toolbox control consists of six interfaces:

  • IToolbox
  • IToolBoxTab
  • ITooBoxItem
  • IToolBoxTabs
  • IToolBoxItems
  • IToolboxEvents

Interfaces related to the GUI

IToolbox

Represents the main control.

IToolBoxTab

Represents a Toolbox tab object. You can rearrange tab positions by dragging them with mouse or by choosing the appropriate command from the popup menu (this does not work correctly).

IToolBoxItem

Represents a Toolbox tab item object.

There are four kinds of tab items (the names are borrowed from VS.NET 2003 Toolbox, and they are self describing I think :-)

  • ToolBoxItemFormatText - As a data contains text value, and displays "text" icon.
  • ToolBoxItemFormatHTML – As a data contains text value, and displays "html" icon.
  • ToolBoxItemFormatGUID – An ActiveX control, as a data contains the GUID of a control and displays the icon from a control DLL.
  • ToolBoxItemFormatPointer – displays "arrow" icon, data property is empty.

Image 2

The functionalities of the described interfaces are nearly the same as that of VS.NET 2003 toolbox interfaces, with some extra methods and properties. Interface IToolboxEvents is a dispatch event interface.

Collection and enumerator interfaces

There are two collections and enumerator interfaces (more on this kind of interfaces is described in this article):

IToolBoxTabs

Collection of Toolbox tab objects.

IToolBoxItems

Collection of Toolbox tab item objects.

These interfaces allow you to manipulate an object from Visual Basic (or VB script) using For..Next and For...Each syntax:

VB
Private Sub Form_Load()
Dim tab As ToolBoxTab
  Set tab = Toolbox1.ToolBoxTabs.Add("Tb 1")
  For Each tab In Toolbox1.ToolBoxTabs
    tb.Name = "Tab"
  Next
End Sub

Events

There is an event dispatch interface IToolboxEvents, and it is related to the Toolbox object.

Property pages

In this version, the Toolbox has its own property page for enabling a popup menu and its "customize" menu item. It has a stock font property page as well.

Image 3

Popup menu

There are two different popup menus for the Tab and the Tab Item. For the Tab Item, you can cut, copy and paste the Tab Item or paste text from the clipboard to the Toolbox as the Tab Item of type ToolBoxItemFormatText.

Image 4

Image 5

References

History

  • October 07th, 2005 – Initial version.

License

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


Written By
CEO bring-it-together s.r.o.
Slovakia Slovakia
Jozef Božek is currently a software engineer at bring-it-together s.r.o. in area of large scale infomation systems and mobile applications development.
He has been developing in C++ nearly full time since 2000, in Java since 2004 and in Objective-C since 2009. He is programming using Java EE SDK, iOS SDK, COM/DCOM, MFC, ATL, STL and so on Smile | :)

Comments and Discussions

 
Generalcannot open include file 'atlres.h'. Pin
luibaiyi29-Jul-07 21:38
luibaiyi29-Jul-07 21:38 
GeneralCant compile.... Pin
daveice30-Mar-06 3:59
daveice30-Mar-06 3:59 

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.