Skip to content

The Commandbar System COM Creation Process

The cCJCommandBarSystem is a subclass of the cCJCommandBars COM class, which is the standard imported Codejock ActiveX class. An object based on cCJCommandBarSystem will be created within a container (e.g., a Panel). When that container is activated, the commandbar system must also be activated.

The cCJCommandBarSystem, which is an ActiveX object, is created, bound to the proxy object, and activated. When this occurs, all of the child commandbar COM objects (menubar, toolbars, menu items, statusbar, and statusbar panes) must also be created. These child objects are all automation objects. As they are created, they are added to the cCJCommandBarSystem object’s COM object model. These automation objects do not actually need to be bound to a DataFlex proxy object. For the commandbar system to work, the only DataFlex object that must be bound to the COM object is the cCJCommandBarSystem object.

While only one statically bound proxy object is actually required, this would create a development environment that would be hard to visually model and harder to program. Since the initial layout of a menu, toolbar, and statusbar system tends to be static, a more static relationship is created between the DataFlex objects and the COM objects. When a cCJCommandBarSystem object is activated, it creates all of the COM objects by sending a create message to the child proxy objects. These immediate child objects will be a menubar, toolbars, and a statusbar.

These objects create the appropriate COM objects, which are bound to their proxy object. They then send the create message to all of their child objects as needed. These child objects will be menu item and statusbar pane objects. When complete, the COM objects are all created, and the menu system is ready to be used. The COM object model created within the cCJCommandBarSystem object will now match the layout of your objects.

When the cCJCommandBarSystem object is activated, it will send itself the message CreateCommandBars. This is the method that sets all of the properties, performs the recursive process to build all of the child COM objects, and restore an existing layout (if appropriate). The recursive creation process is performed by broadcasting the message CreateComInstance to all child objects. These child objects will broadcast CreateComInstance to their children as needed. See CreateCommandBars for a more detailed description of this process.

When the container using the commandbar system is closed, the layout is saved (if appropriate), and the COM commandbar objects are destroyed.

Exceptions

There are two exceptions worth noting:

  • When a cCJMenuItem object is activated, two COM objects, an action and a control, are created. The COM action is bound to the cCJMenuItem object. The COM control is not statically bound to any object (see Item Actions and Controls).

  • Context menu COM objects are not created until they are needed, which is right before they are popped up. The COM instances are destroyed when the context menu is closed.

See Also