你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
问题
文章
话题
登录
注册
在Visual Basic中实现ICommand接口
文章编号:
391
软件:
ArcInfo Desktop 8.3,9.0,ArcEditor 8.3,9.0,ArcView 8.3,9.0
操作系统:
N/A
1 个回复
易智瑞技术支持
赞同来自:
在dll中创建自定义的命令和工具,需要实现ICommand接口,下面就是实现Icommand接口的过程描述。
1 创建一个Visual Basic ActiveX DLL工程;
命名类名称为'clsMyCommand'
命名工程名称为'AoDeomo'
2 在常规声明段,输入
Implements ICommand
3 在代码窗口,使用对象下拉列表(左边),选择Icommand;
4 在代码窗口,使用功能下拉列表,选择ICommand的的成员;
5 为Caption属性写实现代码;
Private Property Get ICommand_Caption() As String
ICommand_Caption = "MyCommand"
End Property
6 为Category属性写实现代码;
Private Property Get ICommand_Category() As String
ICommand_Category = "ArcObjects Custom Commands"
End Property
7 为Check属性写实现代码;
Private Property Get ICommand_Checked() As Boolean
ICommand_Checked = False
End Property
注意:false表示处于非恩下状态
8 为Enabled属性写实现代码;
Private Property Get ICommand_Enabled() As Boolean
ICommand_Enabled = True
End Property
注意:当Enabled属性设为真,用户可以能使用这个按钮。
9 为HelpContextID属性写实现代码
Private Property Get ICommand_HelpContextID() As Long
ICommand_HelpContextID = 0
End Property
注意:0表示没有自定义的帮助。
10 为HelpFile属性写实现代码;
Private Property Get ICommand_HelpFile() As Long
ICommand_HelpFile = ""
End Property
注意:使用0长度的字符串表示没有自定义的帮助文件。
11 为Message属性写实现代码
Private Property Get ICommand_Message() As String
ICommand_Message = "MyCommand"
End Property
注意:这个字符串会在arcmap的状态栏中出现。
12 为Name属性写实现代码;
Private Property Get ICommand_Name() As String
ICommand_Name = "MyCommand"
End Property
13 为Tooltip属性写实现代码;
Private Property Get ICommand_Tooltip() As String
ICommand_Tooltip = "Tooltip: MyCommand"
End Property
注意:这个字符串会在鼠标移动到按钮上时提示。
14 在常规申明段,加上下面两句,这是关系到此命令在arcmap中的使用的。
Option Explicit
Private m_pApp As IApplication
Implements ICommand
15 在OnCreate方法中,传递hook到应用程序;
Private Sub ICommand_OnCreate(ByVal hook As Object)
Set m_pApp = hook
End Sub
16 当按钮被点击时执行的代码写在OnClick事件中;
Private Sub ICommand_OnClick()
MsgBox "MyCommand"
m_pApp.Caption = "The OnClick method for MyCommand has executed"
End Sub
17 在代码窗口,在对象下拉列表中选择Class,在功能下拉列表中选择每一个Class的成员;
18 在Class的Terminate方法中,释放application的引用;
Private Sub Class_Terminate()
Set m_pApp = Nothing
End Sub
19 保存工程;
20 编译dll为AoDemo_clsMyCommand.dll;
21 在ArcMap中使用此自定义的dll;
A 打开ArcMap,点击工具菜单,选择自定义。
B 选择命令。
C 单击 "从文件添加"。
D 选择dll文件,并打开。
E 把此工具拖到某一个工具条上,关闭自定义对话框。
22 测试结果;
创建时间:2004-08-13
最近更新:2004-08-13
【
原文链接
】
http://support.esrichina.com.cn/2004/0813/391.html
要回复问题请先
登录
或
注册
发起人
易智瑞技术支持
相关问题
在Visual studio 2015 中使用 Arcgis API for JavaScript v3.16 如何实现代码智能提示?
在模型构建器中实现计算几何
arcgis api for javascript 4.0版本中找不到draw工具,如何实现拉框查询、几何查询?
ArcGIS Server制作的缓存地图服务中,能否实现大比例尺下楼房阴影类似的3d效果?
怎么通过excel 点集导入arcmap 实现显示多边形
请问如何使用ArcEngine实现(在右击图例中)Convert To Gtaphics这一功能?
用js调用portal中用户所发布的webmap并在该地图上添加点如何用代码实现,我的总是报错。。。。
ARCGIS如何实现,按某字段属性值 批量分类导出成shp
如何实现geodatabase的加密
Engine中如何实现要素图层的反选?
ArcGIS Engine开发的数据库管理系统可以用ArcGIS Runtime完全实现吗
问题状态
最新活动:
2015-12-02 03:37
浏览:
1600
关注:
1
人
1 个回复
易智瑞技术支持
赞同来自:
1 创建一个Visual Basic ActiveX DLL工程;
命名类名称为'clsMyCommand'
命名工程名称为'AoDeomo'
2 在常规声明段,输入
Implements ICommand
3 在代码窗口,使用对象下拉列表(左边),选择Icommand;
4 在代码窗口,使用功能下拉列表,选择ICommand的的成员;
5 为Caption属性写实现代码;
Private Property Get ICommand_Caption() As String
ICommand_Caption = "MyCommand"
End Property
6 为Category属性写实现代码;
Private Property Get ICommand_Category() As String
ICommand_Category = "ArcObjects Custom Commands"
End Property
7 为Check属性写实现代码;
Private Property Get ICommand_Checked() As Boolean
ICommand_Checked = False
End Property
注意:false表示处于非恩下状态
8 为Enabled属性写实现代码;
Private Property Get ICommand_Enabled() As Boolean
ICommand_Enabled = True
End Property
注意:当Enabled属性设为真,用户可以能使用这个按钮。
9 为HelpContextID属性写实现代码
Private Property Get ICommand_HelpContextID() As Long
ICommand_HelpContextID = 0
End Property
注意:0表示没有自定义的帮助。
10 为HelpFile属性写实现代码;
Private Property Get ICommand_HelpFile() As Long
ICommand_HelpFile = ""
End Property
注意:使用0长度的字符串表示没有自定义的帮助文件。
11 为Message属性写实现代码
Private Property Get ICommand_Message() As String
ICommand_Message = "MyCommand"
End Property
注意:这个字符串会在arcmap的状态栏中出现。
12 为Name属性写实现代码;
Private Property Get ICommand_Name() As String
ICommand_Name = "MyCommand"
End Property
13 为Tooltip属性写实现代码;
Private Property Get ICommand_Tooltip() As String
ICommand_Tooltip = "Tooltip: MyCommand"
End Property
注意:这个字符串会在鼠标移动到按钮上时提示。
14 在常规申明段,加上下面两句,这是关系到此命令在arcmap中的使用的。
Option Explicit
Private m_pApp As IApplication
Implements ICommand
15 在OnCreate方法中,传递hook到应用程序;
Private Sub ICommand_OnCreate(ByVal hook As Object)
Set m_pApp = hook
End Sub
16 当按钮被点击时执行的代码写在OnClick事件中;
Private Sub ICommand_OnClick()
MsgBox "MyCommand"
m_pApp.Caption = "The OnClick method for MyCommand has executed"
End Sub
17 在代码窗口,在对象下拉列表中选择Class,在功能下拉列表中选择每一个Class的成员;
18 在Class的Terminate方法中,释放application的引用;
Private Sub Class_Terminate()
Set m_pApp = Nothing
End Sub
19 保存工程;
20 编译dll为AoDemo_clsMyCommand.dll;
21 在ArcMap中使用此自定义的dll;
A 打开ArcMap,点击工具菜单,选择自定义。
B 选择命令。
C 单击 "从文件添加"。
D 选择dll文件,并打开。
E 把此工具拖到某一个工具条上,关闭自定义对话框。
22 测试结果;
创建时间:2004-08-13
最近更新:2004-08-13
【原文链接】
http://support.esrichina.com.cn/2004/0813/391.html
要回复问题请先登录或注册