l1985q
路人甲
路人甲
  • 注册日期2006-09-06
  • 发帖数13
  • QQ
  • 铜币194枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1885回复:3

TOC中怎么知道点击的是那个label还是符号

楼主#
更多 发布于:2007-02-26 22:20
<P>如下函数是判断点击到的类型的代码:<BR>Private Sub TOCControl1_OnMouseUp(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)<BR>    Set m_pLayer = Nothing</P>
<P>    Dim sLayerIsNothing As String<BR>    Dim pObj As IUnknown<BR>    Dim pData As Variant<BR>    Dim pItem As esriTOCControlItem<BR>    Call TOCControl1.HitTest(x, y, pItem, m_pBasicMap, m_pLayer, pObj, pData)</P>
<P>    Dim sLegendGroupInfor As String<BR>    '获取 LegendGroup 的信息<BR>    sLegendGroupInfor = GetLegendGroupInfor(pObj)</P>
<P>    If m_pLayer Is Nothing Then<BR>        sLayerIsNothing = vbCrLf ; "返回图层为 Nothing!"<BR>    Else<BR>        sLayerIsNothing = vbCrLf ; "返回图层名为:" ; m_pLayer.Name<BR>    End If</P>
<P>    Dim sDataInfor As String<BR>    '获取 TocControl.HitTest中 Data 参数的信息,表示选中的索引<BR>    sDataInfor = GetDataInfor(pData)</P>
<P>    Select Case pItem<BR>    Case esriTOCControlItemNone             'None<BR>        MsgBox "未选定任何对象!" ; sLayerIsNothing ; vbCrLf ; sLegendGroupInfor ; vbCrLf ; sDataInfor<BR>    Case esriTOCControlItemMap              '选定了地图<BR>        MsgBox "选定了地图!" ; sLayerIsNothing ; vbCrLf ; sLegendGroupInfor ; vbCrLf ; sDataInfor<BR>    Case esriTOCControlItemLayer            '选定了图层<BR>        'Call PopupMenu(mnuTOCOperator)<BR>        MsgBox "选定了图层!" ; sLayerIsNothing ; vbCrLf ; sLegendGroupInfor ; vbCrLf ; sDataInfor<BR>    Case esriTOCControlItemHeading          '列头<BR>        MsgBox "选定了列头!" ; sLayerIsNothing ; vbCrLf ; sLegendGroupInfor ; vbCrLf ; sDataInfor<BR>    Case esriTOCControlItemLegendClass<BR>        MsgBox "选定了图列!" ; sLayerIsNothing ; vbCrLf ; sLegendGroupInfor ; vbCrLf ; sDataInfor<BR>    End Select<BR>End Sub</P>
<P><BR>'获取 LegendGroup 的信息<BR>Private Function GetLegendGroupInfor(ByVal pLegendGroup As ILegendGroup) As String<BR>    Dim pLegendClass As ILegendClass<BR>    Dim i As Long<BR>    <BR>    If pLegendGroup Is Nothing Then<BR>        GetLegendGroupInfor = "LegendGroup 对象为 Nothing!"<BR>        Exit Function<BR>    End If<BR>    <BR>    GetLegendGroupInfor = "LegendGroup 信息如下:"<BR>    <BR>    For i = 0 To pLegendGroup.ClassCount - 1<BR>        Set pLegendClass = pLegendGroup.Class(i)<BR>        GetLegendGroupInfor = GetLegendGroupInfor ; vbCrLf ; pLegendClass.Label<BR>    Next i<BR>End Function</P>
<P><BR>'获取 TocControl.HitTest中 Data 参数的信息,表示选中的索引<BR>Private Function GetDataInfor(ByVal pData As Variant) As String<BR>    If IsEmpty(pData) Then<BR>        GetDataInfor = "索引为 空值!"<BR>    Else<BR>        GetDataInfor = "索引为 " ; pData ; "!"<BR>    End If<BR>End Function</P>
喜欢0 评分0
bluemaple
路人甲
路人甲
  • 注册日期2007-03-14
  • 发帖数12
  • QQ
  • 铜币179枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2007-07-13 16:40
<P>谢谢楼主了,真好需要</P>
<P>非常感谢</P>
举报 回复(0) 喜欢(0)     评分
icebreaker
路人甲
路人甲
  • 注册日期2003-10-18
  • 发帖数118
  • QQ
  • 铜币400枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2007-03-18 15:38
楼主辛苦<img src="images/post/smile/dvbbs/em02.gif" />
举报 回复(0) 喜欢(0)     评分
whmwxhanshan123
路人甲
路人甲
  • 注册日期2006-06-17
  • 发帖数3108
  • QQ
  • 铜币6445枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2007-02-26 22:28
<img src="images/post/smile/dvbbs/em02.gif" /><STRONG>精华</STRONG>感谢楼主<img src="images/post/smile/dvbbs/em06.gif" />
举报 回复(0) 喜欢(0)     评分
游客

返回顶部