向ArcGIS的ToolBarControl中添加任意的windows控件的方法
概要:在使用ArcEngine开发中,给ToolbarControl添加按钮形式的命令项相信大家都很熟悉了,因为网上的例子很多。但这种使用click调用功能的方式只能满足大部分用户在体验方面的需求,除此之外用户很可能要求你在工具条中增加类似文本框,单选框、选择面板,combobox等windows控件,今天有个同事问我这个问题就在这里做一个实例。供大家参考。
具体实现:
1 知识整备
(1 )其实要实现这个效果很简单,只要大家了解Arcgis中的IToolControl接口的使用方法,就不难实现。
IToolControl 这个接口有只有简单的三个方法:
_ZBM8Z6%7B[UEH25S71.jpg)
{
private int _handle = 0;
private ICompletionNotify _CompNotify;
private System.Windows.Forms.ComboBox comboBox = new System.Windows.Forms.ComboBox();
private IHookHelper m_hookHelper = null;
public Command1()
{
this._handle = comboBox.Handle.ToInt32();
comboBox.Items.Add("大家好才是真的好1");
comboBox.Items.Add("大家好才是真的好1");
comboBox.Items.Add("大家好才是真的好1");
}
#region Overriden Class Methods
/// <summary>
/// Occurs when this command is created
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
if (hook == null)
return;
try
{
m_hookHelper = new HookHelperClass();
m_hookHelper.Hook = hook;
if (m_hookHelper.ActiveView == null)
m_hookHelper = null;
}
catch
{
m_hookHelper = null;
}
if (m_hookHelper == null)
base.m_enabled = false;
else
base.m_enabled = true;
// TODO: Add other initialization code
}
/// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
// TODO: Add Command1.OnClick implementation
}
#endregion
#region IToolControl 成员
public bool OnDrop(esriCmdBarType barType)
{
if (barType == esriCmdBarType.esriCmdBarTypeToolbar)
{
return true;
}
else return false;
}
public void OnFocus(ICompletionNotify complete)
{
_CompNotify = complete;
}
public int hWnd
{
get
{
return _handle;
}
}
#endregion
}
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.SystemUI; namespace AddCustomControlToToolbar
{
/// <summary>
/// Command that works in ArcMap/Map/PageLayout
/// </summary>
[Guid("7e8238b9-b38c-417c-894f-34ca9d99b634")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("AddCustomControlToToolbar.Command1")]
public sealed class Command1 : BaseCommand, IToolControl
{
#region COM Registration Function(s)
[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryRegistration(registerType); //
// TODO: Add any COM registration code here
//
} [ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType); //
// TODO: Add any COM unregistration code here
//
} #region ArcGIS Component Category Registrar generated code
/// <summary>
/// Required method for ArcGIS Component Category registration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryRegistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxCommands.Register(regKey);
ControlsCommands.Register(regKey);
}
/// <summary>
/// Required method for ArcGIS Component Category unregistration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryUnregistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxCommands.Unregister(regKey);
ControlsCommands.Unregister(regKey);
} #endregion
#endregion private int _handle = ;
private ICompletionNotify _CompNotify;
private System.Windows.Forms.ComboBox comboBox = new System.Windows.Forms.ComboBox();
private IHookHelper m_hookHelper = null;
public Command1()
{
this._handle = comboBox.Handle.ToInt32();
comboBox.Items.Add("大家好才是真的好1");
comboBox.Items.Add("大家好才是真的好1");
comboBox.Items.Add("大家好才是真的好1");
} #region Overriden Class Methods /// <summary>
/// Occurs when this command is created
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
if (hook == null)
return; try
{
m_hookHelper = new HookHelperClass();
m_hookHelper.Hook = hook;
if (m_hookHelper.ActiveView == null)
m_hookHelper = null;
}
catch
{
m_hookHelper = null;
} if (m_hookHelper == null)
base.m_enabled = false;
else
base.m_enabled = true; // TODO: Add other initialization code
} /// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
// TODO: Add Command1.OnClick implementation
} #endregion #region IToolControl 成员 public bool OnDrop(esriCmdBarType barType)
{
if (barType == esriCmdBarType.esriCmdBarTypeToolbar)
{
return true;
}
else return false;
} public void OnFocus(ICompletionNotify complete)
{
_CompNotify = complete;
} public int hWnd
{
get
{
return _handle;
}
} #endregion
}
}
向ArcGIS的ToolBarControl中添加任意的windows控件的方法的更多相关文章
- 向ArcGIS的ToolBarControl中添加任意的windows组建的方法[转]
向ArcGIS的ToolBarControl中添加任意的windows组建的方法[转] Link: http://www.cnblogs.com/mymhj/archive/2012/10/12/27 ...
- android 给LinearLayout中添加一定数量的控件,并让着一定数量的控件从右到左移动,每隔若干秒停顿一下,最后一个view链接第一个view,然后继续移动循环往复,形成一个死循环简单动画效果
主类:IndexAnimationLinearLayout.java package com.yw.sortlistview; import java.util.ArrayList; import j ...
- (转载)VC/MFC 工具栏上动态添加组合框等控件的方法
引言 工具条作为大多数标准的Windows应用程序的 一个重要组成部分,使其成为促进人机界面友好的一个重要工具.通过工具条极大方便了用户对程序的操作,但是在由Microsoft Visual C++开 ...
- VC/MFC 工具栏上动态添加组合框等控件的方法
引言 工具条作为大多数标准的Windows应用程序的一个重要组成部分,使其成为促进人机界面友好的一个重要工具.通过工具条极大方便了用户对程序的操作,但是在由Microsoft Visual C++开发 ...
- C#中缓存的使用 ajax请求基于restFul的WebApi(post、get、delete、put) 让 .NET 更方便的导入导出 Excel .net core api +swagger(一个简单的入门demo 使用codefirst+mysql) C# 位运算详解 c# 交错数组 c# 数组协变 C# 添加Excel表单控件(Form Controls) C#串口通信程序
C#中缓存的使用 缓存的概念及优缺点在这里就不多做介绍,主要介绍一下使用的方法. 1.在ASP.NET中页面缓存的使用方法简单,只需要在aspx页的顶部加上一句声明即可: <%@ Outp ...
- js如何实现动态的在表格中添加和删除行?(两种方法)
js如何实现动态的在表格中添加和删除行?(两种方法) 一.总结 1.table元素有属性和一些方法(js使用) 方法一:添加可通过在table的innerHTML属性中添加tr和td来实现 tab.i ...
- 利用ArcGIS Engine、VS .NET和Windows控件开发GIS应用
Dixon 原文 用ArcGIS Engine.VS .NET和Windows控件开发GIS应用 此过程说明适合那些使用.NET建立和部署应用的开发者,它描述了使用ArcGIS控件建立和部署 ...
- ArcGIS ElementLayer上放置Windows控件
ElementLayer是ArcGIS API for Silverlight/WPF中的一种图层类型,主要用来承载Silverlight/WPF中的UIElement对象(UIElement),使用 ...
- Android 可单选多选的任意层级树形控件
花了几天研究了下鸿扬大神的博客<Android打造任意层级树形控件,考验你的数据结构和设计>,再结合公司项目改造改造,现在做个笔记. 先看看Demo的实现效果.首先看的是多选效果 再看看单 ...
随机推荐
- JavaScript垃圾回收(二)——垃圾回收算法
一.引用计数(Reference Counting)算法 Internet Explorer 8以下的DOM和BOM使用COM组件所以是引用计数来为DOM对象处理内存,引用计数的含义是跟踪记录每个值被 ...
- Linux驱动开发——__stringify
在Linux内核中有一个宏__stringify,在include/linux/stringify.h定义如下: #ifndef __LINUX_STRINGIFY_H #define __LINUX ...
- android布局文件中android:icon="?attr/menuIconCamera"找不到对应图标路径
如 <item android:id="@+id/camera" android:title="Camera" android:icon="?a ...
- 番外特别篇之 为什么我不建议你直接使用UIImage传值?--从一个诡异的相册九图连读崩溃bug谈起
关于"番外特别篇" 所谓"番外特别篇",就是系列文章更新期间内,随机插入的一篇文章.目前我正在更新的系列文章是 实现iOS图片等资源文件的热更新化.但是,这两天 ...
- 非常完善的Log4net详细说明
4.1.6 <filter> 过滤器,只能作为<appender>的子元素. 支持的属性: type 必须的,Filter的类型 支持的子元素: param 0个或多个, ...
- WinPhone学习笔记(三)——WinPhone的动画
这段时间又一直赶任务,结果没有去学习,也没有去写博文,这个动画的内容很早就学了,但是一直没把它整理成博文,现在终于有空就弄一下. 开始先讲讲在WinPhone中做动画有两种动画类型,一种是基于帧动画另 ...
- C# WebClient 使用http免费代理。
static void Main(string[] args) { WebClient client = new WebClient(); client.Encoding = Encoding.Get ...
- 使用DocX开源组件,实现动态数据的填充。
1.先解释一下,什么叫做动态数据,动态数据指的是,一条数据的格式固定,但数据的条数不固定. 2.应用环境,在一个表格当中如果,现在表格有三行n列,如果你需要在表格第一行后添加同等规格的一行或n行,应该 ...
- When to close cursors using MySQLdb
http://stackoverflow.com/questions/5669878/when-to-close-cursors-using-mysqldb I'm building a WSGI w ...
- Time series database
https://en.wikipedia.org/wiki/Time_series_database https://influxdb.com/docs/v0.9/introduction/getti ...