木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
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>
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
31楼#
发布于:2005-07-07 12:35
<P>pmap已经定义了,自己调试程序看看哪里错了,</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
32楼#
发布于:2005-07-06 22:58
<P>Set pMap = MapControl1.Map  '这里mapcontrol改成你的控件名字就可以了</P>
<P>老大,这一行有错,他提示说变量未定义,这个是控件名称,还要定义么?</P>
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
33楼#
发布于:2005-07-05 23:57
谢谢了,谢谢了,我试试
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
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>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
35楼#
发布于:2005-07-05 10:46
顶一下!
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
36楼#
发布于:2005-07-01 13:34
谢谢老大,我已经拷到一个类模块中了,他是提示用户类型未定义,象你说的,怎么修改它的定义呢?谢谢,不好意思哈,问这么菜的问题,小弟实在不知道啊
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
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>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
木白林
路人甲
路人甲
  • 注册日期2004-03-19
  • 发帖数319
  • QQ
  • 铜币824枚
  • 威望0点
  • 贡献值0点
  • 银元0个
38楼#
发布于:2005-06-30 21:48
<STRONG>不是对话框那种,就是点击菜单,相应的shape或者tif或者卫星影象文件就直接在mapcontrol中显示出来了,不好意思,小弟是半路出家,还请指教,最好能依葫芦画瓢就最好了。还有,我用AE+VB,AE的toolbarcontrol支不支持VB中的菜单编辑器呢?谢谢各位了!!!</STRONG>
心情卡片 一起分享...
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
39楼#
发布于:2005-06-28 16:42
<P>调用arcmap的对话框?</P>
[此贴子已经被作者于2005-6-28 16:51:36编辑过]
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部