Add any method of Windows build to ArcGIS Toolbarcontrol [go]

Source: Internet
Author: User

to ArcGIS of the Toolbarcontrol Add any of the Windows How to build [ go ]

Link: Span style= "color: #666666; Font-family:verdana "> http://www.cnblogs.com/mymhj/archive/2012/10/12/2721036.html

Summary: In use Arcengine in development, give Toolbarcontrol Add a command item in the form of a button I'm sure we're all familiar with this, because there are many examples online. However, this method of using the Click Invoke feature can only meet the needs of most users in terms of experience, in addition to the user is likely to require you to add similar text boxes in the toolbar , Radio box, selection panel , ComboBox wait Windows control, today a colleague asked me this question to do an example here. For everyone's reference.

Specific implementation:

? 1 Knowledge-servicing

? (1) in fact, to achieve this effect is very simple, as long as you understand Arcgis in the Itoolcontrol the use of interfaces is not difficult to achieve.

?? Itoolcontrol This interface has only a simple three methods:

??

hwnd : is a read-only property that returns the control to the caller handle .

OnDrop : Is a method that is used by the caller to verify whether the current control can be dragged.

onfocus: is a method that is used to invoke notification of the current item that you have focused on.

(2) In addition to understanding Itoolcotrol interface, you must also have the ability to know how to create Arcgis command plug-in knowledge, and how to invoke the plug-in method.

??

2 Implement

?? with a simple Combobox For example:

??? public sealed Class Command1:basecommand, Itoolcontrol
??? {
?

??????? privat e 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 (" everyone is really good. 1 ");
??????????? ComboBox.Items.Add (" everyone is really good. 1 ");
??????????? ComboBox.Items.Add (" everyone is really good. 1 ");
???????}

??????? #region Overriden Class Methods

??????? <summary>
??????? Occurs when the 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 the this command is clicked
??????? </summary>
??????? public override void OnClick ()
??????? {
??????????? Todo:add Command1.onclick Implementation
??????? }

??????? #endregion

??????? #region Itoolcontrol member

??????? 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
??? }

3 Achieve Results

?

According to this example can be added, the other Windows Control

??

4? Instance Code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.