YouTube | Facebook | X(Twitter) | RSS

Engine で ITool からフォームを取得する方法

2016/9/1 (木)

public override void OnClick()
{
    m_map = m_hookHelper.FocusMap;
    // このツールが格納されているForm1を取得
    try
    {
        // ツールバーのバディからMapControlを取得
        IToolbarControl2 tlb = (IToolbarControl2)m_hookHelper.Hook;
        IMapControl4 mapctrl = (IMapControl4)tlb.Buddy;
         
        // AxMapControlが格納されているForm1を取得
        IntPtr ptr = (System.IntPtr)mapctrl.hWnd;
        System.Windows.Forms.Control cntrl = System.Windows.Forms.Control.FromHandle(ptr);
        frm1 = cntrl.FindForm();
    }
    catch (Exception ex) 
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
    }
}
// Form1のコントロールでtxtCenterX, txtCenterY, txtRadiusに値を入れる
private void SetControlProps(string sX, string sY, string sRadius)
{
    try
    {
        System.Windows.Forms.TextBox txtX = (System.Windows.Forms.TextBox)frm1.Controls.Find("txtCenterX", true)[0];
        System.Windows.Forms.TextBox txtY = (System.Windows.Forms.TextBox)frm1.Controls.Find("txtCenterY", true)[0];
        System.Windows.Forms.TextBox txtRadius = (System.Windows.Forms.TextBox)frm1.Controls.Find("txtRadius", true)[0];
        txtX.Text = sX ;
        txtY.Text = sY ;
        txtRadius.Text = sRadius;
    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
    }
   
}

関連記事

  • この記事を書いた人

羽田 康祐

伊達と酔狂のGISエンジニア。GIS上級技術者、Esri認定インストラクター、CompTIA CTT+ Classroom Trainer、潜水士、PADIダイブマスター、四アマ。WordPress は 2.1 からのユーザーで歴だけは長い。 代表著書『地図リテラシー入門―地図の正しい読み方・描き方がわかる』 GIS を使った自己紹介はこちら。ESRIジャパン(株)所属、元青山学院大学非常勤講師を兼務。日本地図学会第31期常任委員。発言は個人の見解です。

-プログラミング, ArcGIS
-,

WINGFIELD since1981をもっと見る

今すぐ購読し、続きを読んで、すべてのアーカイブにアクセスしましょう。

続きを読む