|
阅读:2891回复:10
VBA中的UIToolControl1_MouseDown
<P>VBA中的UIToolControl1_MouseDown在VB中对应着什么?应该用什么来表示UIToolControl1_MouseDown?</P>
<img src="images/post/smile/dvbbs/em12.gif" /> |
|
|
1楼#
发布于:2005-09-06 15:40
<P>Dim pCom As ICommand</P>
<P>Set pCom = New YourTool ’YourTool Implements esriSystemUI.ICommand and esriSystemUI.ITool <BR>pCom.OnCreate (mapCtrl.object)<BR>pCom.OnClick<BR>If TypeOf pCom Is esriSystemUI.ITool Then<BR> Set mapCtrl.CurrentTool = pCom<BR>End If</P> |
|
|
|
2楼#
发布于:2005-09-06 16:03
能不能具体点,我还不太明白<img src="images/post/smile/dvbbs/em12.gif" />
|
|
|
3楼#
发布于:2005-09-06 19:18
<P>你的意思是把VBA中的UITool实现的功能转成VB来实现?</P>
<P>如果是这样的话</P> <P>我建议你:</P> <P>1、首先把你在UIToolControl1中的代码,移植到一个实现 esriSystemUI.ICommand and esriSystemUI.ITool这两个的接口的一个类模块</P> <P>例如Identify:</P> <P>Implements esriSystemUI.ICommand<BR>Implements esriSystemUI.ITool<BR>Dim m_mapctrl As MapControl 'ArcMap application<BR> <BR>Private Property Get ICommand_Enabled() As Boolean<BR> <BR> ' TOD Add your implementation here<BR> ' ICommand_Enabled =<BR> <BR>End Property<BR> <BR>Private Property Get ICommand_Checked() As Boolean<BR> <BR> ' TOD Add your implementation here<BR> ' ICommand_Checked =<BR> <BR>End Property<BR> <BR>Private Property Get ICommand_Name() As String<BR> <BR> ' TOD Add your implementation here<BR> ICommand_Name = "IdentifyTool"<BR> <BR>End Property<BR> <BR>Private Property Get ICommand_Caption() As String<BR> <BR> ' TOD Add your implementation here<BR> ICommand_Caption = "IdentifyTool"<BR> <BR>End Property<BR> <BR>Private Property Get ICommand_Tooltip() As String<BR> <BR> ' TOD Add your implementation here<BR> ' ICommand_Tooltip =<BR> <BR>End Property<BR> <BR>Private Property Get ICommand_Message() As String<BR> <BR> ' TOD Add your implementation here<BR> ' ICommand_Message =<BR> <BR>End Property<BR> <BR>Private Property Get ICommand_HelpFile() As String<BR> <BR> ' TOD Add your implementation here<BR> ' ICommand_HelpFile =<BR> <BR>End Property<BR> <BR>Private Property Get ICommand_HelpContextID() As Long<BR> <BR> ' TOD Add your implementation here<BR> ' ICommand_HelpContextID =<BR> <BR>End Property<BR> <BR>Private Property Get ICommand_Bitmap() As esriSystem.OLE_HANDLE<BR> <BR> ' TOD Add your implementation here<BR> ' ICommand_Bitmap =<BR> <BR>End Property<BR> <BR>Private Property Get ICommand_Category() As String<BR> <BR> ' TOD Add your implementation here<BR> ' ICommand_Category =<BR> <BR>End Property<BR> <BR>Private Sub ICommand_OnCreate(ByVal hook As Object)<BR> <BR> ' TOD Add your implementation here<BR> Set m_mapctrl = gfrmMap.mapCtrl<BR> 'Set m_mapctrl.object = hook<BR>End Sub<BR> <BR>Private Sub ICommand_OnClick()<BR> <BR> ' TOD Add your implementation here<BR> <BR>End Sub<BR> <BR>Private Property Get ITool_Cursor() As esriSystem.OLE_HANDLE<BR> <BR> ' TOD Add your implementation here<BR> ' ITool_Cursor =<BR> <BR>End Property<BR> <BR>Private Sub ITool_OnMouseDown(ByVal Button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)<BR> <BR> ' TOD Add your implementation here<BR> <BR> Dim pActiveView As IActiveView<BR> Dim pIdentifyDialog As IIdentifyDialog<BR> Dim pIdentifyDialogProps As IIdentifyDialogProps<BR> Dim pEnumLayer As IEnumLayer<BR> Dim pLayer As ILayer</P> <P> <BR> Set pActiveView = m_mapctrl.ActiveView</P> <P> 'Create a new IdentifyDialog and associate it<BR> 'with the focus map and the map's display<BR> Set pIdentifyDialog = New IdentifyDialog<BR> Set pIdentifyDialogProps = pIdentifyDialog 'QI<BR> Set pIdentifyDialog.Map = m_mapctrl.Map<BR> Set pIdentifyDialog.Display = pActiveView.ScreenDisplay<BR> <BR> 'Clear the dialog on each mouse click<BR> pIdentifyDialog.ClearLayers<BR> <BR> 'Perform an identify on all of the layers the dialog<BR> 'says are searchable<BR> Set pEnumLayer = pIdentifyDialogProps.Layers<BR> pEnumLayer.Reset<BR> Set pLayer = pEnumLayer.Next<BR> Do While Not pLayer Is Nothing<BR> pIdentifyDialog.AddLayerIdentifyPoint pLayer, x, y<BR> Set pLayer = pEnumLayer.Next<BR> Loop<BR> <BR> pIdentifyDialog.Show</P> <P>End Sub<BR> <BR>Private Sub ITool_OnMouseMove(ByVal Button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)<BR> <BR> ' TOD Add your implementation here<BR> <BR>End Sub<BR> <BR>Private Sub ITool_OnMouseUp(ByVal Button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)<BR> <BR> ' TOD Add your implementation here<BR> <BR>End Sub<BR> <BR>Private Sub ITool_OnDblClick()<BR> <BR> ' TOD Add your implementation here<BR> <BR>End Sub<BR> <BR>Private Sub ITool_OnKeyDown(ByVal keyCode As Long, ByVal shift As Long)<BR> <BR> ' TOD Add your implementation here<BR> <BR>End Sub<BR> <BR>Private Sub ITool_OnKeyUp(ByVal keyCode As Long, ByVal shift As Long)<BR> <BR> ' TOD Add your implementation here<BR> <BR>End Sub<BR> <BR>Private Function ITool_OnContextMenu(ByVal x As Long, ByVal y As Long) As Boolean<BR> <BR> ' TOD Add your implementation here<BR> <BR>End Function<BR> <BR>Private Sub ITool_Refresh(ByVal hdc As esriSystem.OLE_HANDLE)</P> <P> ' TOD Add your implementation here</P> <P>End Sub<BR> <BR>Private Function ITool_Deactivate() As Boolean<BR> <BR> ' TOD Add your implementation here<BR> ITool_Deactivate = True<BR>End Function<BR></P> <P>其实以上很多代码都是由Add-ins中的ESRI InterFace Implementer这一工具直接生成的,真正要写的代码主要是ITool_OnMouseDown事件中,这就是你的UITool MouseDown实现的功能。</P> <P>2、然后就像我上一贴那样使用你的类模块</P> |
|
|
|
4楼#
发布于:2005-09-07 09:10
<P>不好意思,还是运行不了</P>
<P>Dim pCom As ICommand</P> <P>Set pCom = New YourTool ’YourTool Implements esriSystemUI.ICommand and esriSystemUI.ITool <BR>pCom.OnCreate (mapCtrl.object)<BR>pCom.OnClick<BR>If TypeOf pCom Is esriSystemUI.ITool Then<BR> Set mapCtrl.CurrentTool = pCom<BR>End If</P> <P>其中的Set pCom = New YourTool ’YourTool 是什么?</P> <P>还有Dim m_mapctrl As MapControl 'As后没有MapControl</P> <img src="images/post/smile/dvbbs/em12.gif" /> |
|
|
5楼#
发布于:2005-09-07 11:18
<P>YourTool:改成类模块的名字啊</P>
<P>'As后没有MapControl:难道你的VB程序里没有使用MapControl,当然如果你使用了PageLayoutControl,那请改成PageLayoutControl。</P> |
|
|
|
6楼#
发布于:2005-09-07 14:25
<P>初学者,请楼上见谅</P>
|
|
|
7楼#
发布于:2005-09-07 21:06
呵呵,自己也是在和你的交流中得到进步,话语有不得体的地方,还请见谅
|
|
|
|
8楼#
发布于:2005-09-07 21:27
<P> 随便用什么来表示,你可以表示为一切vb里面可能发生的动作,只要你需要</P>
<img src="images/post/smile/dvbbs/em02.gif" /> |
|
|
|
9楼#
发布于:2005-09-08 08:35
<P>感谢感谢,大家一起学习一起进步</P>
<img src="images/post/smile/dvbbs/em03.gif" /> |
|
上一页
下一页