Tuesday, August 02, 2011

ActiveX Controls for interactive Runtime Debugging of COM Objects

Overview

When developing COM Objects, I often wished to have something similar to VB's Properties- or Debug-window to retrieve or interactively change an object's current properties at runtime. There exists a small number of little demo apps (like the AtlCon sample in MSDN) about property browsing, but in general those were not functional enough for me - one cannot browse properties which take one or more extra parameters (not just setting/returning one value), one cannot invoke methods, one can only browse a COM object's default interface (although most objects do implement more than one interface), and one can only do the browsing during design time.

To circumvent those restrictions, I implemented three ActiveX controls doing the job for me (see screenshots above):
One for browsing through an object model hierarchy (example above: MS Word), one for browsing all implemented interfaces (restriction: only registered interfaces described in a typelib are listed) of a specified object (example above: a MS ProgressBar control on a VB-Form), and one for browsing an objects current property values and interactively change (i.e. invoke) the objects properties and methods (example above: MS Word's "Normal Template" object).

Furthermore, the source code for the controls shows how to retrieve Type Information via the Type Description Interfaces ITypeInfo, ITypeLib, etc. and the Type Information structures (see MSDN: PlatformSDK/Component Services/COM/Automation).


Control Description

1. Running Object Table Browser Control

This control enables the browsing through an object model hierarchy similar to VB's Debug-window in a treeview. There are two 'categories' of objects to be browsed: objects registered in the "Running Object Table" (see MSDN) and objects added either programmatically or interactively through Drag 'n Drop from the "object browser control" or the "Invoke Dialog" (see "4. Drag and Drop" below). Clicking the right mouse button inside the control shows the following context menu:

ROTMenu.gif

Read more: Codeproject
QR: objectbrowser.aspx

Posted via email from Jasper-Net