110楼#
发布于:2005-07-26 10:53
<P>本例要实现的是如何创建定制的MultiItem。</P>
<P 21pt; TEXT-INDENT: -21pt">l 要点</P> <P 0.05pt; TEXT-INDENT: 17.95pt">需要实现IMultiItem接口,但不需要同时实现Icommand接口。IMultiItem接口包括Caption,itemCaption,ItemBitmap,ItemEnabled,ItemChecked, Message及Name等属性和OnItemClick, OnPopup事件。</P> <P 17.95pt">·itemCaption,ItemBitmap,ItemEnabled,ItemChecked等属性的参数index表示当前Item的下标索引。</P> <P> ·OnPopup事件的参数hook同Icommand接口的OnCreate事件的参数hook一样,传入ArcGIS的Application实例,同时,该事件返回将要显示的Item数目。</P> <P 0.1pt; TEXT-INDENT: 17.85pt">·OnItemClick事件的参数Index表示用户当前点击的Item的索引,用户根据该索引分别定义点击各个Item时实现的功能。</P> <P 21pt; TEXT-INDENT: -21pt">l 程序说明</P> <P 21pt">程序在类模块中实现IMultiItem接口来创建定制自己的MultiItem。</P> <P 21pt; TEXT-INDENT: -21pt">l 代码</P> <P> <TABLE height=43 width=541 align=center border=0> <TR> <TD width=531> <P 37.4pt; TEXT-INDENT: -37.3pt">Option Explicit</P> <P 37.4pt; TEXT-INDENT: -37.3pt">Implements IMultiItem</P> <P 37.4pt; TEXT-INDENT: -37.3pt">Private m_pApp As IApplication<BR>'ArcMap的Document</P> <P 37.4pt; TEXT-INDENT: -37.3pt">Private m_pMxDoc As IMxDocument<BR>'当前Focus Map</P> <P 37.4pt; TEXT-INDENT: -37.3pt">Private m_pMap As IMap<BR>'Map中的层数</P> <P 37.4pt; TEXT-INDENT: -37.3pt">Private m_pLayerCnt As Long </P> <P 37.4pt; TEXT-INDENT: -37.3pt">Private Property Get IMultiItem_Caption() As String<BR> IMultiItem_Caption = "ZoomToLayers"</P> <P 37.4pt; TEXT-INDENT: -37.3pt">End Property</P> <P 37.4pt; TEXT-INDENT: -37.3pt">Private Property Get IMultiItem_HelpContextID() As Long</P> <P 37.4pt; TEXT-INDENT: -37.3pt">End Property </P> <P 37.4pt; TEXT-INDENT: -37.3pt">Private Property Get IMultiItem_HelpFile() As String</P> <P 37.4pt; TEXT-INDENT: -37.3pt">End Property</P> <P 37.4pt; TEXT-INDENT: -37.3pt">Private Property Get IMultiItem_ItemBitmap(ByVal Index As Long) As esriCore.OLE_HANDLE</P> <P 0.05pt">End Property</P> <P 0.05pt">Private Property Get IMultiItem_ItemCaption(ByVal Index As Long) As String Dim i As Integer<BR> ' 遍历每一个层<BR> For i = 0 To m_pLayerCnt - 1<BR> ' 如果层号与当前Item的Index相同,就设置该Item的Caption<BR> If Index = i Then<BR> IMultiItem_ItemCaption = "Zoom to " ; m_pMap.Layer(i).Name<BR> End If<BR> Next<BR>End Property</P> <P 0.05pt">Private Property Get IMultiItem_ItemChecked(ByVal Index As Long) As Boolean<BR>End Property<BR> </P> <P 0.05pt">Private Property Get IMultiItem_ItemEnabled(ByVal Index As Long) As Boolean<BR> Dim i As Integer<BR> ' 遍历每一个层<BR> For i = 0 To m_pLayerCnt - 1<BR> '如果层号与当前Item的Index相同,则当前Item的Enable根据该层的Visible设置。<BR> If Index = i Then<BR> If m_pMap.Layer(i).Visible Then<BR> IMultiItem_ItemEnabled = True<BR> End If<BR> End If<BR> Next<BR>End Property</P> <P 0.05pt">Private Property Get IMultiItem_Message() As String<BR> IMultiItem_Message = "Zooms to the layer."<BR>End Property</P> <P 0.05pt">Private Property Get IMultiItem_Name() As String<BR> IMultiItem_Name = "ZoomMulti"<BR>End Property </P> <P>Private Sub IMultiItem_OnItemClick(ByVal Index As Long)<BR> Dim i As Integer<BR> Dim pEnv As IEnvelope<BR> Dim m_BookMark As IAOIBookmark<BR> ' 遍历每一个层<BR> For i = 0 To m_pLayerCnt – 1<BR> '如果层号与当前Item的Index相同,则以该层的AreaOfInterest 为范围执行Zoom<BR> If Index = i Then<BR> Set pEnv = m_pMap.Layer(i).AreaOfInterest<BR> Set m_BookMark = New AOIBookmark<BR> Set m_BookMark.Location = pEnv<BR> m_BookMark.ZoomTo m_pMap<BR> m_pMxDoc.ActiveView.Refresh<BR> End If<BR> Next<BR>End Sub </P> <P>Private Function IMultiItem_OnPopup(ByVal hook As Object) As Long<BR> Set m_pApp = hook<BR> ' 获取Map中的层数<BR> Set m_pMxDoc = m_pApp.Document<BR> Set m_pMap = m_pMxDoc.FocusMap<BR> m_pLayerCnt = m_pMap.LayerCount<BR> ' 显示的Item数等于层数<BR> IMultiItem_OnPopup = m_pLayerCnt<BR>End Function </P></TD></TR></TABLE></P> |
|
|
111楼#
发布于:2005-07-26 10:53
如何创建定制的工具条(Tool Bar)
<P 17.95pt">本例要实现的是如何创建定制的工具条(Tool Bar)。就必须在类模块中实现IToolBarDef接口。IToolBarDef接口包括 Caption、ItemCount及Name三个属性和GetItemInfo方法。</P> <P 21pt; TEXT-INDENT: -21pt">l 要点</P> <P 21pt">通过在类模块中实现IToolBarDef接口。IToolBarDef接口包括 Caption、ItemCount及Name三个属性和GetItemInfo方法。</P> <P 17.95pt">·ItemCount属性表示ToolBar显示的条目(Button、Tool或其它控件)数。 </P> <P 17.95pt">· GetItemInfo方法定义工具条上各条目的CLSID,其中,参数<I>pos</I>表示条目在ToolBar中的位置,<I>itemDef</I> 是定义相应位置的条目的IItemDef 对象。</P> <P 17.85pt">·工具条条目的CLSID分为两种:</P> <P 17.95pt">1、系统CLSID,代表ArcGIS的一个功能,其引用方式为"esriCore.命令名称",如"esriCore.AddDataCommand"、"esriCore.FileSaveCommand"等。</P> <P 17.95pt">2、用户定制CLSID,表示用户自己定义的功能。其引用方式为"工程名称.定制功能类名称",如" ToolBarDef.ClsBar "。必须注意,这里“定制功能类名称”是工程中实现的一个功能类名称,“工程名称”即为当前工程的名称(不是DLL文件名,也不是工具条的名称),每次新建一个工程时,系统默认的工程名在某些情况下无法使用(在中文版的VB中是一个乱字符),必须改名后方能用。</P> <P 0cm; TEXT-INDENT: 0cm">l 程序说明</P> <P 17.95pt">程序在类模块中实现IToolBarDef接口来创建自己的工具条(ToolBar)。</P> <P 21pt; TEXT-INDENT: -21pt">l 代码</P> <P> <TABLE height=43 width=541 align=center border=0> <TR> <TD align=left width=531> <P>Option Explicit<BR>Implements IToolBarDef </P> <P>Private Property Get IToolBarDef_Caption() As String<BR>IToolBarDef_Caption = "CustomToolBar"<BR>End Property</P> <P>Private Sub IToolBarDef_GetItemInfo(ByVal pos As Long, ByVal itemDef As_ esriCore.IItemDef)<BR> '这里假设在当前工程(工程名称为ToolBarDef)中定义了一个类模块(名为ClsBar),<BR> '它实现了Icommand接口(可参照1.2.1)<BR> Select Case pos<BR> Case 0<BR> '用户自定义条目<BR> itemDef.ID = "ToolBarDef.ClsBar"<BR> itemDef.Group = False<BR> Case 1<BR> '系统条目<BR> itemDef.ID = "esriCore.AddDataCommand"<BR> itemDef.Group = False<BR> End Select<BR>End Sub </P> <P 37.3pt; TEXT-INDENT: -37.3pt">Private Property Get IToolBarDef_ItemCount() As Long<BR>IToolBarDef_ItemCount = 2</P> <P>End Property </P> <P 37.3pt; TEXT-INDENT: -37.3pt">Private Property Get IToolBarDef_Name() As String<BR>IToolBarDef_Name = "CustomToolBar"</P> <P>End Property</P></TD></TR></TABLE></P> |
|
|
112楼#
发布于:2005-07-26 10:52
<P><FONT size=2>本例要实现的是如何创建定制的Tool<FONT face="MS UI Gothic"> </FONT></FONT></P>
<P> 要点</P> <P 17.95pt">用户在类模块中实现Icommand(参见1.2.1)和ITool接口。ITool接口包括 mouse move, mouse button press/release, keyboard key press/release, double-click以及right click等事件、Cursor属性和Refresh方法。</P> <P 17.95pt">Tool既具有Button的功能,又具有与ArcMAP界面交互的功能,Button的功能代码必须写在Icommand的OnClick事件中,而所有实现交互功能的代码必须写在Itool接口的各个事件中。Itool接口的各个事件,用户可以在其中写入相关代码,表示用户与ArcMAP界面交互时一旦触发某事件要实现的功能。</P> <P 21pt; TEXT-INDENT: -21pt">l 程序说明</P> <P 21pt; TEXT-INDENT: -21pt"> 程序在类模块中实现Icommand和Itool接口来创建自己的Tool.</P> <P 21pt; TEXT-INDENT: -21pt">l 代码</P> <P> <TABLE height=43 width=541 align=center border=0> <TR> <TD width=531> <P>Option Explicit<BR>'实现Icommand和Itool接口<BR>Implements ICommand<BR>Implements ITool<BR>Dim m_pApplication As IApplication <BR>Dim m_pBitmap As IPictureDisp<BR>Dim m_pCursor As IpictureDisp </P> <P>Private Sub Class_Initialize()<BR> Set m_pBitmap = LoadResPicture(101, 0)<BR> '从.RES文件中调入ID为102的图片作为按下Tool后的MouseCursor<BR> Set m_pCursor = LoadResPicture(102, 2)<BR>End Sub </P> <P>Private Property Get ICommand_Bitmap() As esriCore.OLE_HANDLE<BR> ICommand_Bitmap = m_pBitmap<BR>End Property</P> <P>Private Property Get ICommand_Caption() As String<BR> ICommand_Caption = "MyTool"<BR>End Property </P> <P>Private Property Get ICommand_Category() As String<BR> ICommand_Category = "MyCustomTools"<BR>End Property</P> <P>Private Property Get ICommand_Checked() As Boolean<BR>End Property</P> <P>Private Property Get ICommand_Enabled() As Boolean<BR> ICommand_Enabled = True<BR>End Property</P> <P>Private Property Get ICommand_HelpContextID() As Long<BR>End Property </P> <P>Private Property Get ICommand_HelpFile() As String<BR>End Property </P> <P>Private Property Get ICommand_Message() As String<BR> ICommand_Message = "This is my custom tool"<BR>End Property</P> <P>Private Property Get ICommand_Name() As String<BR> ICommand_Name = "MyCustomTool_MyTool"<BR>End Property</P> <P>Private Sub ICommand_OnClick()<BR> '加入按下按钮时实现的功能代码<BR> MsgBox "Clicked on my command"<BR>End Sub</P> <P>Private Sub ICommand_OnCreate(ByVal hook As Object)<BR> '获取ArcMAP的Application实例<BR> Set m_pApplication = hook<BR>End Sub</P> <P>Private Property Get ICommand_Tooltip() As String<BR> ICommand_Tooltip = "MyTool"<BR>End Property </P> <P>Private Property Get ITool_Cursor() As esriCore.OLE_HANDLE<BR> ITool_Cursor = m_pCursor<BR>End Property</P> <P>Private Function ITool_Deactivate() As Boolean<BR> '如果ITool_Deactivate设为False,则Tool不可用<BR> ITool_Deactivate = True<BR>End Function</P> <P>Private Function ITool_OnContextMenu(ByVal X As Long, ByVal Y As Long) As Boolean<BR> '在这里可以加入用户代码,点击Mouse右键时显示一个定制的context menu <BR>End Function </P> <P>Private Sub ITool_OnDblClick()<BR> '在这里加入Mouse双击时的功能代码<BR>End Sub </P> <P>Private Sub ITool_OnKeyDown(ByVal keyCode As Long, ByVal Shift As Long)<BR>End Sub </P> <P>Private Sub ITool_OnKeyUp(ByVal keyCode As Long, ByVal Shift As Long)<BR>End Sub </P> <P 32pt; TEXT-INDENT: -32pt">Private Sub ITool_OnMouseDown(ByVal Button As Long, ByVal Shift As Long, _<BR>ByVal X As Long, ByVal Y As Long)<BR> '加入Mouse单击时的功能代码<BR> If Button = 1 Then<BR> Dim pPoint As IPoint<BR> Dim pMxApplication As IMxApplication<BR> Set pMxApplication = m_pApp<BR> Set pPoint=pMxApplication.Display.DisplayTransformation.ToMapPoint(X, Y)<BR> m_pApplication.StatusBar.Message(0) = Str(pPoint.X) ; "," ; Str(pPoint.Y)<BR> End If</P> <P>End Sub</P> <P>Private Sub ITool_OnMouseMove(ByVal Button As Long, ByVal Shift As Long, _<BR> ByVal X As Long, ByVal Y As Long)<BR> '加入Mouse移动时的功能代码<BR> m_pApplication.StatusBar.Message(0) = "ITool_OnMouseMove"<BR>End Sub</P> <P>Private Sub ITool_OnMouseUp(ByVal Button As Long, ByVal Shift As Long, _<BR> ByVal X As Long, ByVal Y As Long)<BR> '加入释放Mouse时的功能代码<BR> m_pApplication.StatusBar.Message(0) = "ITool_OnMouseUp"<BR>End Sub</P> <P>Private Sub ITool_Refresh(ByVal hDC As esriCore.OLE_HANDLE)<BR>End Sub <P>Private Property Get ICommand_Name() As String<BR> ICommand_Name = "MyCustomTool_MyTool"<BR>End Property</P> <P>Private Sub ICommand_OnClick()<BR> '加入按下按钮时实现的功能代码<BR> MsgBox "Clicked on my command"<BR>End Sub</P> <P>Private Sub ICommand_OnCreate(ByVal hook As Object)<BR> '获取ArcMAP的Application实例<BR> Set m_pApplication = hook<BR>End Sub</P> <P>Private Property Get ICommand_Tooltip() As String<BR> ICommand_Tooltip = "MyTool"<BR>End Property </P> <P>Private Property Get ITool_Cursor() As esriCore.OLE_HANDLE<BR> ITool_Cursor = m_pCursor<BR>End Property</P> <P>Private Function ITool_Deactivate() As Boolean<BR> '如果ITool_Deactivate设为False,则Tool不可用<BR> ITool_Deactivate = True<BR>End Function</P> <P>Private Function ITool_OnContextMenu(ByVal X As Long, ByVal Y As Long) As Boolean<BR> '在这里可以加入用户代码,点击Mouse右键时显示一个定制的context menu <BR>End Function </P> <P>Private Sub ITool_OnDblClick()<BR> '在这里加入Mouse双击时的功能代码<BR>End Sub </P> <P>Private Sub ITool_OnKeyDown(ByVal keyCode As Long, ByVal Shift As Long)<BR>End Sub </P> <P>Private Sub ITool_OnKeyUp(ByVal keyCode As Long, ByVal Shift As Long)<BR>End Sub </P> <P 32pt; TEXT-INDENT: -32pt">Private Sub ITool_OnMouseDown(ByVal Button As Long, ByVal Shift As Long, _<BR>ByVal X As Long, ByVal Y As Long)<BR> '加入Mouse单击时的功能代码<BR> If Button = 1 Then<BR> Dim pPoint As IPoint<BR> Dim pMxApplication As IMxApplication<BR> Set pMxApplication = m_pApp<BR> Set pPoint=pMxApplication.Display.DisplayTransformation.ToMapPoint(X, Y)<BR> m_pApplication.StatusBar.Message(0) = Str(pPoint.X) ; "," ; Str(pPoint.Y)<BR> End If</P> <P>End Sub</P> <P>Private Sub ITool_OnMouseMove(ByVal Button As Long, ByVal Shift As Long, _<BR> ByVal X As Long, ByVal Y As Long)<BR> '加入Mouse移动时的功能代码<BR> m_pApplication.StatusBar.Message(0) = "ITool_OnMouseMove"<BR>End Sub</P> <P>Private Sub ITool_OnMouseUp(ByVal Button As Long, ByVal Shift As Long, _<BR> ByVal X As Long, ByVal Y As Long)<BR> '加入释放Mouse时的功能代码<BR> m_pApplication.StatusBar.Message(0) = "ITool_OnMouseUp"<BR>End Sub</P> <P>Private Sub ITool_Refresh(ByVal hDC As esriCore.OLE_HANDLE)<BR>End Sub</P></TD></TR></TABLE></P> |
|
|
113楼#
发布于:2005-07-26 10:51
如何创建定制的按钮(Button)
<P 17.95pt">本例要实现的是如何创建定制的按钮(Button)。</P> <P 39pt; TEXT-INDENT: -39pt">l 要点</P> <P 0.05pt; TEXT-INDENT: 17.95pt">用户通过在类模块中实现ICommand接口来创建定制的按钮(COM command)。ICommand接口包括 caption、 name、 category、 bitmap、 message(StatusBarr的提示信息)、 tooltip(微帮助)、 help context id 、help file、enabled以及checked等十个属性和OnCreate、 OnClick两个事件。从Icommand接口的OnCreate事件中获取的ArcMap的Application实例必须用一个公共变量保存,以便在其它事件中(或者其它接口的事件中甚至整个工程中)使用。</P> <P 17.95pt">·OnCreate事件的参数hook传入的是一个Object,也就是ArcMAP的Application实例,可把它赋给一个IApplication接口的变量,便获得了ArcMAP的实例。</P> <P 17.95pt; TEXT-INDENT: 0.05pt">·在OnClick事件中写入相关代码,表示按下按钮时要实现的功能.</P> <P 39pt; TEXT-INDENT: -39pt">l 程序说明</P> <P 17.95pt; TEXT-INDENT: 0.05pt">程序在类模块中实现Icommand接口来创建自己的按钮(Button)</P> <P 39pt; TEXT-INDENT: -39pt">l 代码</P> <P> <TABLE height=2202 width=541 align=center border=0> <TR> <TD width=531 height=2198> <P><CODE>Option Explicit</CODE><CODE><BR>'实现Icommand接口<BR>Implements ICommand<BR>Dim m_pPicture as Picture<BR>Dim m_pApplication As IApplication<BR><BR>Private Sub Class_Initialize()<BR> '调入.RES文件中ID为101的BitMap作为该按钮的显示图片<BR> Set m_pPicture = LoadResPicture(101, vbResBitmap)<BR>End Sub</CODE></P> <P><CODE>Private Property Get ICommand_Bitmap() As esriCore.OLE_HANDLE<BR> ICommand_Bitmap = m_pPicture<BR>End Property</CODE></P> <P><CODE>Private Property Get ICommand_Caption() As String<BR> ICommand_Caption = "Create Button"<BR>End Property</CODE></P> <P><CODE>Private Property Get ICommand_Category() As String<BR> ICommand_Category = " Create Button "<BR>End Property</CODE></P> <P><CODE>Private Property Get ICommand_Checked() As Boolean<BR>End Property</CODE></P> <P><CODE>Private Property Get ICommand_Enabled() As Boolean<BR> ICommand_Enabled = True<BR>End Property</CODE></P> <P><CODE>Private Property Get ICommand_HelpContextID() As Long<BR>End Property</CODE></P> <P><CODE>Private Property Get ICommand_HelpFile() As String<BR>End Property</CODE></P> <P><CODE>Private Property Get ICommand_Message() As String<BR>End Property</CODE></P> <P>Private Property Get ICommand_Name() As String<BR>ICommand_Name = " CreateButton "<BR>End Property</P> <P>Private Sub ICommand_OnClick()<BR> '加入按下按钮时实现的功能代码。在这里,<BR> '按钮按下时显示ArcMap的Document的Tittle<BR> Dim pDocument As IDocument<BR> Set pDocument = m_pApplication.Document<BR> MsgBox pDocument.Title<BR>End Sub</P> <P>Private Sub ICommand_OnCreate(ByVal hook As Object)<BR> '获取ArcMap的Application实例<BR> Set m_pApplication = hook<BR>End Sub</P> <P>Private Property Get ICommand_Tooltip() As String<BR> ICommand_Tooltip = " Create Button "<BR>End Property</P> <P>Private Sub ITool_OnDblClick()<BR> '在这里加入Mouse双击时的功能代码<BR>End Sub </P> <P>Private Sub ITool_OnKeyDown(ByVal keyCode As Long, ByVal Shift As Long)<BR>End Sub </P> <P>Private Sub ITool_OnKeyUp(ByVal keyCode As Long, ByVal Shift As Long)<BR>End Sub </P> <P 32pt; TEXT-INDENT: -32pt">Private Sub ITool_OnMouseDown(ByVal Button As Long, ByVal Shift As Long, _<BR>ByVal X As Long, ByVal Y As Long)<BR> '加入Mouse单击时的功能代码<BR> If Button = 1 Then<BR> Dim pPoint As IPoint<BR> Dim pMxApplication As IMxApplication<BR> Set pMxApplication = m_pApp<BR> Set pPoint=pMxApplication.Display.DisplayTransformation.ToMapPoint(X, Y)<BR> m_pApplication.StatusBar.Message(0) = Str(pPoint.X) ; "," ; Str(pPoint.Y)<BR> End If</P> <P>End Sub</P> <P>Private Sub ITool_OnMouseMove(ByVal Button As Long, ByVal Shift As Long, _<BR> ByVal X As Long, ByVal Y As Long)<BR> '加入Mouse移动时的功能代码<BR> m_pApplication.StatusBar.Message(0) = "ITool_OnMouseMove"<BR>End Sub</P> <P>Private Sub ITool_OnMouseUp(ByVal Button As Long, ByVal Shift As Long, _<BR> ByVal X As Long, ByVal Y As Long)<BR> '加入释放Mouse时的功能代码<BR> m_pApplication.StatusBar.Message(0) = "ITool_OnMouseUp"<BR>End Sub</P> <P>Private Sub ITool_Refresh(ByVal hDC As esriCore.OLE_HANDLE)<BR>End Sub</P></TD></TR></TABLE></P> |
|
|
114楼#
发布于:2005-07-26 10:48
如何在VB环境中利用ArcObjects控件开发EXE
<P> 利用ArcObjects控件开发EXE的前三步类似于1.1.2中开发“Acrtive Dll”的前三步,唯一不同的是在“New Project”对话框中选择“Standard EXE”。<BR> 4、点击<PROJECT>菜单项中的<COMPONENTS>项,打开“Components”对话框,如图13。<BR></P> <DIV align=center><IMG src="http://www.sdgis.com/Data/Chinese/Develop/ArcGISBook/1/pic/wd0104-1.jpg" border=0></DIV> <P align=center>图13 打开Components对话框</P> <P>???? 5、在“Components”对话框中,切换到Controls页,并选中“ESRI MapControl”项,点击<应用>或<确定>按钮,如图14。<BR></P> <DIV align=center><IMG src="http://www.sdgis.com/Data/Chinese/Develop/ArcGISBook/1/pic/wd0104-2.jpg" border=0></DIV> <P align=center>图14 Components对话框</P> <P>???? 6、如图15所示,加载MapControl控件之后,在VBE的控件面板中出现了MapControl控件图标,用户便可以象在Form中添加Button一样在Form中添加MapControl控件,并利用它开发EXE。<BR></P> <DIV align=center><IMG src="http://www.sdgis.com/Data/Chinese/Develop/ArcGISBook/1/pic/wd0104-3.jpg" border=0></DIV> <P align=center>图15 添加MapControl控件</P> |
|
|
115楼#
发布于:2005-07-26 10:47
如何在ArcMap中加载利用ArcObjects组件开发的ActiveX DLL
<P> 用户通过1.1.2中介绍的方法开发好一个ActiveX DLL程序后,便可根据实际需要,在ArcMap环境下加载这个ActiveX DLL程序。其一般步骤如下:<BR> 1、用鼠标右击任何工具栏(条),点击弹出的上托式菜单中的<CUSTOMIZE>菜单项(参见图4)。<BR> 2、在Customize对话框中,根据被加载DLL的类型切换到“Toolbars”或者“Commands”页(参见图5),然后点击<ADD From File>按钮。<BR> 3、在“打开文件”对话框中(Windows通用“打开文件”对话框,图略),选择被加载的Dll文件,并点击<打开>按钮。<BR> 4、如果加载是“Commands”,则在图5所示的对话框中显示加载的Command,并可以将其拖置于任何工具条上;如果加载是“ToolBars”,则在图12所示的对话框中显示加载的ToolBar,选中后即可在ArcMap中显示。<BR></P> <DIV align=center><IMG src="http://www.sdgis.com/Data/Chinese/Develop/ArcGISBook/1/pic/wd0103-1.jpg" border=0></DIV> |
|
|
116楼#
发布于:2005-07-26 10:43
<P>如何在VB环境中利用ArcObjects组件开发ActiveX DLL</P>
<P><FONT face="MS UI Gothic" size=2> </FONT>1.1.1节讨论了如何在ArcGis的VBA环境中编程,虽然通过这种方式可以完成大多数用户的定制需求,但是,在某些情况下,对于特殊的应用,用户需要脱离ArcGIS环境而在VB开发环境中开发外部独立的应用程序,这种外部独立的应用程序有两种形式: ActiveX DLL和Standard EXE。Standard EXE的开发将在1.1.4中讨论,本节将讨论ActiveX DLL的开发,其关键是引用ArcObjects对象库和实现ArcObjects接口(例如ICommand,ITool,IToolBar等)。<BR> 下面介绍在VB环境利用ArcObjects组件开发ActiveX DLL的一般步骤。<BR> 1、启动VB开发环境,在图7所示的“New Project”对话框中选择“ActiveX DLL”项,并点击<打开>按钮,进入VBE环境。<BR></P> <DIV align=center><IMG src="http://www.sdgis.com/Data/Chinese/Develop/ArcGISBook/1/pic/wd0102-1.jpg" border=0></DIV> <P align=center>图7 New Project对话框</P> <P>???? 2、引用ArcObjects对象库:首先点击<PROJECT>菜单中的<REFERENCES>项,如图8,进入对象库引用对话框,如图9。<BR></P> <DIV align=center><IMG src="http://www.sdgis.com/Data/Chinese/Develop/ArcGISBook/1/pic/wd0102-2.jpg" border=0></DIV> <P align=center>图8 启动对象库引用对话框<BR></P> <DIV align=center><IMG src="http://www.sdgis.com/Data/Chinese/Develop/ArcGISBook/1/pic/wd0102-3.jpg" border=0></DIV> <P align=center>图9 对象库引用对话框</P> <P>???? 3、对象库引用对话框(图9)中选中“Esri ArcMap Object Library ”和“Esri Object Library” 两项,并点击<OK>按钮,返回VBE环境。<BR> 4、一般在类模块中写入实现特定ArcObjects接口的代码,如图10,然后运行<FILE>菜单中的<MAKE project1.dll>项,生成DLL文件,如图11。(project1.dll随项目名改变)。<BR></P> <DIV align=center><IMG src="http://www.sdgis.com/Data/Chinese/Develop/ArcGISBook/1/pic/wd0102-4.jpg" border=0></DIV> <P align=center>图10 类模块编辑窗口<BR></P> <DIV align=center><IMG src="http://www.sdgis.com/Data/Chinese/Develop/ArcGISBook/1/pic/wd0102-5.jpg" border=0></DIV> <P align=center>图11 生成DLL文件<BR></P> |
|
|
上一页
下一页