Using the Dockable ActiveX Control Container
The documentation is updated for use with AutoCAD 2007 or newer
versions.
Using the Command Line
The application provides the “DOCKABLE_CONTAINER” command to create
the docking ActiveX control container window. This command requires the ProgID
or CLSID string of the ActiveX control to proceed. The ProgID is a string that
uniquely identifies the ActiveX control.
For example, using the Microsoft Calendar control registered on
your system:
Command: DOCKABLE_CONTAINER
ProgID of control: mscal.calendar
NOTE: The ActiveX control needs to be installed and
registered with the system.
Using the Automation API

The figure above shows the relationship between the container
window and the ActiveX control. The container window sizes the ActiveX control
to fit its client area minus the grip bar if docked. The container window then
makes available an Automation interface (IAcadDockableContainer) for the
ActiveX control to have programmatic access to its properties and methods. If an
ActiveX control wants access to this Automation interface, then it must
implement the IRetrieveDockableContainer interface.
The container window will ask the ActiveX control for its
IRetrieveDockableContainer interface immediately after it creates the control
but before displaying it. If the control accepts the request, then the container
calls the SetDockContainer() method of the interface
and passes in an IAcadDockableContainter interface. The control can then keep
this interface around if it wants to access the containers properties / methods
at a later time or use it for initialization and discard it.
Below is an example of a VB implemented
IRetrieveDockableContainer:
‘ Global variable so the interface can be used at a later time if needed.
Dim dockContainer As AcadDockableContainer
Implements IRetrieveDockableContainer
Private Sub IRetrieveDockableContainer_SetDockContainer(ByVal newVal As IAcadDockableContainer)
‘ Keep this interface around by assigning it to a global variable.
Set dockContainer = newVal
‘ Allow docking only on the left and right sides of AutoCAD
dockContainer.EnableDockPositions = acDockLeft + acDockRight
‘ We want the window to appear as a floating window the very first time.
‘ The size of the floating window is specified below.
Dim rect(0 To 3) As Integer
rect(0) = 50 ' left
rect(1) = 50 ' top
rect(2) = 300 ' right
rect(3) = 300 ' bottom
dockContainer.SetPreferredDockPosition acFloating, rect
End Sub
As the code sample shows, the implementation of
SetDockContainer() is a great place to call
EnableDockPositions and SetPreferredDockPosition(). This is because it is called
only once after the ActiveX control is created and before it is displayed for
the first time.
Included with this application are two sample ActiveX controls (DOCKTEST.OCX)
which were created using Visual Basic 6.0. The entire source code for these controls are also included for reference. Use REGSVR32.EXE
if you want to sample the controls without rebuilding the OCX. The two ProgIDs
serviced by DOCKTEST.OCX are “Docktest.TestControl” and “Docktest.Dockbars.”
Automation API Reference
IAcadDockableContainer
Used by the ActiveX control to set / get property values
or call methods on the ActiveX control container window.
| Methods |
Description |
| Float |
Undocks the container window. |
| Dock |
Docks the container window. |
| SetPreferredDockPosition |
Specifies the preferred docking mode and position. Use one
of the following constants as the first argument: acFloating,
acDockLeft, acDockTop, acDockRight, or acDockBottom. The second
argument is optional and only used if acFloating is specified as
the first argument. This optional argument is of type VARIANT
and contains a safe array of four integers containing the
floating window’s rectangle. The array is read as: left, top,
right bottom. The preferred docking mode is ONLY used when the
last known docking mode, position, and size are unavailable.
This is equivalent to a default mode for the ActiveX control the
first time it is used with ACCONT17.ARX on a computer. |
| Hide |
Hides the container window. |
| Show |
Shows the container window. |
| Destroy |
Destroys the container window. (Use sparingly as AutoCAD
will not save this container window’s state.) |
| Properties |
Description |
| Caption |
Sets / retrieves a string value which is used as the caption
for the container window when it is floating. |
| AllowDocking |
Sets / retrieves a boolean value which indicates whether the
container window can be docked or not. |
| EnableDockPositions |
Sets / retrieves which sides of the container window can be
docked to. A value of zero means docking is disabled. The
constants acDockLeft, acDockTop, acDockRight, and acDockBottom
can be added together to specify the desired docking locations.
Also, constant acDockAny is available to conveniently specify
all sides. Do NOT use the acFloating constant with this
property. |
| IsFloating |
Retrieves a boolean value of VARIANT_TRUE if the container
window is currently floating. |
| Application |
Retrieves the IAcadApplication interface to the AutoCAD
application object. |
| Name |
Retrieves a string value which represents the ActiveX
control’s CLSID. |
| Control |
Retrieves the IDispatch of the ActiveX control being hosted. |
| KeepFocus |
Sets / retrieves a boolean value which indicates whether to
allow AutoCAD to take the focus away from the control when the
mouse is moved outside the docking window. |
| Visible |
Retrieves a boolean value which indicates whether to docking
window is currently visible or not. |
| Width |
Retrieves the width of the docking window in pixels. |
| Height |
Retrieves the height of the docking window in pixels. |
| DockedPosition |
Retrieves the side of the frame window where the container
window is docked. The following constants can be returned:
acDockLeft, acDockTop, acDockRight, acDockBottom, or acFloating. |
| AutoHide |
Sets / retrieves a boolean value which indicates whether to
hide and show the docking window automatically when entering and
leaving zero document mode. |
| Events |
Description |
| OnDock |
Called when the docking window is docked to AutoCAD’s frame
window. |
| OnFloat |
Called when the docking window is undocked from AutoCAD’s
frame window. |
| OnClose |
Called when the docking window’s close button (ie. “X”) is
used. |
| OnDestroy |
Called when the docking window is unloaded from memory. |
| OnContextMenu |
Called when the context menu is being requested (opened).
You can dynamically add and remove items from the menu inside
this method call. |
| OnCommand |
Called when a menu item in the context menu is selected. |
| OnDocumentActivated |
Called when a document is activated. The IDispatch of the
AcadDocument object is passed in for convenience. |
IAcadDockableMenu
Used to add and remove items from the context menu.
| Methods |
Description |
| InsertItem |
Used to add a menu item to the context menu. Three arguments
are supplied for specifying the position, command id, and
caption of the new menu item. |
| InsertSeparator |
Used to add a separator line by position to the context
menu. |
| RemoveItem |
Used to remove a menu item by position from the context
menu. |
| EnableItem |
Used to enable a menu item by position in the context menu. |
| DisableItem |
Used to disable a menu item by position in the context menu. |
| CheckItem |
Used to check a menu item by position in the context menu. |
| UncheckItem |
Used to uncheck a menu item by position in the context menu. |
| Properties |
Description |
| Application |
Retrieves the IAcadApplication interface to the AutoCAD
application object. |
| Count |
Retrieves the number of menu items in the context menu. |
IRetrieveDockableContainer
Used to retrieve the Automation interface for the
dockable container window. Implemented by the ActiveX Control author.
| Methods |
Description |
| SetDockContainer |
Receives one argument of type IAcadDockableContainer. |
IAcadDockableContainers
Used by the ActiveX control to set / get property values
or call methods on the ActiveX control container window.
| Methods |
Description |
| Item |
Gets a specific container window from the collection. The
specific container window can be specified by using an index
number (zero based) or a string containing the CLSID or ProgID
of the ActiveX control. The return value is of type
IAcadDockableContainer2. |
| Add |
Creates and adds a container window to the collection.
Receives one argument which is a string containing the CLSID or
ProgID of the ActiveX control. The return value is of type
IAcadDockableContainer2. |
| Properties |
Description |
| Application |
Retrieves the IAcadApplication interface to the AutoCAD
application object. |
| Count |
Retrieves the number of container windows in the collection. |
Constants
| Name |
Value |
Description |
| acFloating |
0xFFFFFFFF |
Creates a floating window. Only for use with the
SetPreferredDockPosition method. |
| acDockAny |
0x0000F000 |
Allow docking to all sides. |
| acDockLeft |
0x00001000 |
Allow docking to the left side. |
| acDockTop |
0x00002000 |
Allow docking along the top. |
| acDockRight |
0x00004000 |
Allow docking to the right side. |
| acDockBottom |
0x00008000 |
Allow docking along the bottom. |
Disclaimer
THIS PROGRAM IS PROVIDED "AS IS" AND WITH ALL FAULTS. YOU ASSUME ALL
RESPONSIBILITY WITH REGARDS TO THIS PROGRAM AND SOURCE CODE BY USING IT.
AutoCAD 2000 through 2008
Permission to use, copy, modify, and distribute this
software in object code form for any purpose and without fee is hereby
granted, provided that it does not break existing users of Accont.arx, Accont16.arx,
Accont17.arx, Accont18.arx.
You do this by changing the ARX and TLB file names, the
registered command name, the registry key entries (both demand loading
and COM support), and all the guids used.
|