找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1977|回复: 1

[分享] AutoCad Dockable Container

[复制链接]

已领礼包: 859个

财富等级: 财运亨通

发表于 2014-6-23 20:56:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
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
0.jpg             
                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 ReferenceIAcadDockableContainer
                        Used by the ActiveX control to set / get property values                         or call methods on the ActiveX control container window.            
MethodsDescription
FloatUndocks the container window.
DockDocks 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 the dockable container on a computer.                                    
HideHides the container window.
ShowShows the container window.
Destroy                                        Destroys the container window. (Use sparingly as AutoCAD                                         will not save this container window’s state.)                                    
PropertiesDescription
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.                                
ControlRetrieves 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.                                
WidthRetrieves the width of the docking window in pixels.
HeightRetrieves 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.                                
EventsDescription
OnDockCalled when the docking window is docked to AutoCAD’s frame window.
OnFloatCalled when the docking window is undocked from AutoCAD’s frame window.
OnCloseCalled when the docking window’s close button (ie. “X”) is used.
OnDestroyCalled 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.                                    
OnCommandCalled 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.
MethodsDescription
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.                                
InsertSeparatorUsed to add a separator line by position to the context menu.
RemoveItemUsed to remove a menu item by position from the context menu.
EnableItemUsed to enable a menu item by position in the context menu.
DisableItemUsed to disable a menu item by position in the context menu.
CheckItemUsed to check a menu item by position in the context menu.
UncheckItemUsed to uncheck a menu item by position in the context menu.
PropertiesDescription
Application                                        Retrieves the IAcadApplication interface to the AutoCAD                                         application object.                                    
CountRetrieves 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.                
MethodsDescription
SetDockContainerReceives 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.                 
MethodsDescription
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.                                
PropertiesDescription
Application                                        Retrieves the IAcadApplication interface to the AutoCAD                                         application object.                                    
CountRetrieves the number of container windows in the collection.
Constants
NameValueDescription
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 2010
                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, Accont2010.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.

For 2010  32bit

For 2010 64bit

Latest source code for AutoCAD 2010:

Latest source code for AutoCAD 2007 and AutoCAD 2008:

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 859个

财富等级: 财运亨通

 楼主| 发表于 2014-6-23 20:58:53 | 显示全部楼层
0.jpg
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-15 13:31 , Processed in 0.170797 second(s), 38 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表