YouTube | Facebook | X(Twitter) | RSS

ITOCControl::HitTest メソッドの使用例

2016/9/1 (木)

'ITOCControl::HitTestメソッド サンプル
'ITOCControl::HitTestメソッドによるデータフレーム、レイヤ、凡例オブジェクトの取得方法
Private Sub TOCControl1_OnMouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
     
    'TOCControlの取得
    Dim pTOCControl As ITOCControl
    Dim pItem As esriTOCControlItem
    Dim pMap As IMap                    'データフレーム
    Dim pLayer As ILayer                'レイヤ
    Dim pLegendGroup As ILegendGroup    'シンボル
    Dim pIndex As Variant               'シンボルに応じた引数
     
    'HitTest
    Set pTOCControl = TOCControl1.object
    pTOCControl.HitTest x, y, pItem, pMap, pLayer, pLegendGroup, pIndex
     
    'オブジェクトが取得できない場合
    If pItem = esriTOCControlItemLegendClass Then
        '個々のシンボルを取得
        Dim pLegendClass As ILegendClass
        Set pLegendClass = pLegendGroup.Class(pIndex)
             
        Dim pSymbol As ISymbol
        Set pSymbol = pLegendClass.Symbol
         
        Dim pSimpleFillSymbol As ISimpleFillSymbol
         
        'ポリゴンシンボルの場合シンボル色を変更
        If TypeOf pSymbol Is ISimpleFillSymbol Then
         
            MsgBox "SimplePolygonSymbol"
             
            'ポリゴン色を赤に変更
            Set pSimpleFillSymbol = pSymbol
            Dim pRgbColor As IRgbColor
            Set pRgbColor = New RgbColor
             
            pRgbColor.RGB = vbRed
            pSimpleFillSymbol.Color = pRgbColor
        End If
         
        'ラスタのカラーランプシンボル
        If TypeOf pSymbol Is IColorRampSymbol Then MsgBox "ColorRampSymbol " & pIndex
         
        'ラスタの個別カラー
        If TypeOf pSymbol Is IColorSymbol Then MsgBox "ColorSymbol " & pIndex
    End If
 
     
    'TOCの再描画
    pTOCControl.Update
         
End Sub

関連記事

  • この記事を書いた人

羽田 康祐

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

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

WINGFIELD since1981をもっと見る

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

続きを読む