30楼#
发布于:2005-07-08 11:22
<P>实在不知道哪里出问题了,我把全部都帖出来吧,谢谢各位了</P>
<P>下面这个是在窗体加载中的代码,调用类模块</P> <P> 'Create a MenuDef object<BR> Dim pMenuDef As esriSystemUI.IMenuDef<BR> Set pMenuDef = New NavigationMenu<BR> <BR> <BR> 'Add to the end of the Toolbar - it will be the 6th item<BR> ToolbarControl1.AddItem pMenuDef, , , , , esriCommandStyleMenuBar</P> <P>下面这个是类模块的完整代码:</P> <P>Option Explicit<BR>Dim FEATURELAYER As IFeatureLayer<BR>Implements IMenuDef</P> <P>Private Property Get IMenuDef_Caption() As String<BR> IMenuDef_Caption = "土壤"<BR>End Property</P> <P>Private Sub IMenuDef_GetItemInfo(ByVal pos As Long, ByVal itemDef As esriSystemUI.IItemDef)<BR> Select Case pos 'Commands for the menu - the object browser lists these commands<BR> Case 0<BR> <BR> Call AddShapeFile<BR> <BR> Case 1<BR> itemDef.ID = "esriControlCommands.ControlsMapZoomOutFixedCommand"<BR> Case 2<BR> itemDef.ID = "esriControlCommands.ControlsMapFullExtentCommand"<BR> itemDef.Group = True<BR> Case 3<BR> itemDef.ID = "esriControlCommands.ControlsMapZoomToLastExtentBackCommand"<BR> Case 4<BR> itemDef.ID = "esriControlCommands.ControlsMapZoomToLastExtentForwardCommand"<BR> End Select<BR>End Sub</P> <P><BR>Public Sub AddShapeFile()<BR> Dim pWorkspaceFactory As IWorkspaceFactory<BR> Dim pFeatureWorkspace As IFeatureWorkspace<BR> Dim pFeatureLayer As IFeatureLayer<BR> Dim pMap As IMap<BR> <BR> 'Create a new ShapefileWorkspaceFactory object and open a shapefile folder<BR> Set pWorkspaceFactory = New ShapefileWorkspaceFactory<BR> Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile("d:\Program Files\ArcGIS\DeveloperKit\Samples\Data\World", 0)<BR> 'Create a new FeatureLayer and assign a shapefile to it<BR> Set pFeatureLayer = New FEATURELAYER<BR> Set pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass("Country")<BR> pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName<BR> 'Add the FeatureLayer to the focus map<BR> Set pMap = MapControl1.Map '这里mapcontrol改成你的控件名字就可以了</P> <P> pMap.AddLayer pFeatureLayer<BR>End Sub</P> <P><BR>Private Property Get IMenuDef_ItemCount() As Long<BR> IMenuDef_ItemCount = 5<BR>End Property</P> <P>Private Property Get IMenuDef_Name() As String<BR> IMenuDef_Name = "Navigation"<BR>End Property<BR></P> |
|
|
31楼#
发布于:2005-07-07 12:35
<P>pmap已经定义了,自己调试程序看看哪里错了,</P>
|
|
|
32楼#
发布于:2005-07-06 22:58
<P>Set pMap = MapControl1.Map '这里mapcontrol改成你的控件名字就可以了</P>
<P>老大,这一行有错,他提示说变量未定义,这个是控件名称,还要定义么?</P> |
|
|
33楼#
发布于:2005-07-05 23:57
谢谢了,谢谢了,我试试
|
|
|
34楼#
发布于:2005-07-05 13:13
<P> <DEVELOPENV>Public Sub AddShapeFile()<BR> Dim pWorkspaceFactory As IWorkspaceFactory<BR> Dim pFeatureWorkspace As IFeatureWorkspace<BR> Dim pFeatureLayer As IFeatureLayer<BR> Dim pMap As IMap<BR> <BR> 'Create a new ShapefileWorkspaceFactory object and open a shapefile folder<BR> Set pWorkspaceFactory = New ShapefileWorkspaceFactory<BR> Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile("C:\Program Files\ArcGIS\DeveloperKit\Samples\Data\World", 0)<BR> 'Create a new FeatureLayer and assign a shapefile to it<BR> Set pFeatureLayer = New FeatureLayer<BR> Set pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass("Country")<BR> pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName<BR> 'Add the FeatureLayer to the focus map<BR> Set pMap = <FONT color=#f73809>mapcontrol</FONT>.map '<FONT color=#421ae6>这里mapcontrol改成你的控件名字就可以了</FONT></P>
<P> pMap.AddLayer pFeatureLayer<BR>End Sub</DEVELOPENV><BR></P> |
|
|
35楼#
发布于:2005-07-05 10:46
顶一下!
|
|
|
36楼#
发布于:2005-07-01 13:34
谢谢老大,我已经拷到一个类模块中了,他是提示用户类型未定义,象你说的,怎么修改它的定义呢?谢谢,不好意思哈,问这么菜的问题,小弟实在不知道啊
|
|
|
37楼#
发布于:2005-07-01 09:46
<P>toolbarcontrol不支持vb的菜单编辑器,在AE中要打开shape和tif要分别编写函数来打开,下面是添加shape file的arcmap vba的程序,修改下imap等定义就可以转到ae中使用</P>
<P> <DEVELOPENV>Public Sub AddShapeFile()<BR> Dim pWorkspaceFactory As IWorkspaceFactory<BR> Dim pFeatureWorkspace As IFeatureWorkspace<BR> Dim pFeatureLayer As IFeatureLayer<BR> Dim pMxDocument As IMxDocument<BR> Dim pMap As IMap<BR> <BR> 'Create a new ShapefileWorkspaceFactory object and open a shapefile folder<BR> Set pWorkspaceFactory = New ShapefileWorkspaceFactory<BR> Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile("C:\Program Files\ArcGIS\DeveloperKit\Samples\Data\World", 0)<BR> 'Create a new FeatureLayer and assign a shapefile to it<BR> Set pFeatureLayer = New FeatureLayer<BR> Set pFeatureLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass("Country")<BR> pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName<BR> 'Add the FeatureLayer to the focus map<BR> Set pMxDocument = Application.Document<BR> Set pMap = pMxDocument.FocusMap<BR> pMap.AddLayer pFeatureLayer<BR>End Sub</DEVELOPENV><BR></P> |
|
|
38楼#
发布于:2005-06-30 21:48
<STRONG>不是对话框那种,就是点击菜单,相应的shape或者tif或者卫星影象文件就直接在mapcontrol中显示出来了,不好意思,小弟是半路出家,还请指教,最好能依葫芦画瓢就最好了。还有,我用AE+VB,AE的toolbarcontrol支不支持VB中的菜单编辑器呢?谢谢各位了!!!</STRONG>
|
|
|
39楼#
发布于:2005-06-28 16:42
<P>调用arcmap的对话框?</P>
[此贴子已经被作者于2005-6-28 16:51:36编辑过]
|
|
|