阅读:3549回复:10
疑惑:如何调用hook?
<P>目标:vb环境中实现融合功能。
问题:不知怎样调用hook来实现下面的FocusMap,苦恼!! ' Public Sub Dissolve() Dim pDoc As IMxDocument Set pDoc = ThisDocument Dim pMap As IMap Set pMap = pDoc.FocusMap</P><img src="images/post/smile/dvbbs/em30.gif" /> |
|
1楼#
发布于:2004-12-15 16:20
<P>顶一下,非常感谢楼上的热情帮助,问题终于解决了。</P><P>以下是经过我修改后的程序,希望会对大家有所用:</P><P><FONT style="BACKGROUND-COLOR: #55aa99"> Dim pMap As IMap
Set pMap = MapControlMain.ActiveView.FocusMap</FONT></P><P>' Find the layer named SDE.New_Shapefile Dim pLayer As ILayer Dim pInputFeatLayer As IFeatureLayer Dim intCount As Integer For intCount = 0 To pMap.LayerCount - 1 Set pLayer = pMap.Layer(intCount) If TypeOf pLayer Is IFeatureLayer Then If pLayer.Name = "New_Shapefile" Then Set pInputFeatLayer = pLayer Exit For End If End If Next If <FONT style="BACKGROUND-COLOR: #c2ee11">pLayer</FONT> Is Nothing Then MsgBox "The SDE.New_Shapefile layer was not found" Exit Sub End If ' Get input table ' Use the ITable interface from the FeatureLayer (not from the FeatureClass) Dim pInputTable As ITable Set pInputTable = pInputFeatLayer <FONT style="BACKGROUND-COLOR: #11ee69"> Dim pTable As ITable Set pTable = pInputTable</FONT></P><P> 前两句是楼上的,后面的是我稍微修改dissolve后的。</P><P> 我是刚开始接触的,以后还得跟大家多多交流 互相学习</P><img src="images/post/smile/dvbbs/em03.gif" /><img src="images/post/smile/dvbbs/em03.gif" /><img src="images/post/smile/dvbbs/em04.gif" /><img src="images/post/smile/dvbbs/em08.gif" /> |
|
2楼#
发布于:2004-12-14 10:13
<P>可以看得出其实你是想得到MapControl中的地图图层。你不用调用HOOK,你直接</P><P>Dim pMap As IMap
Set pMap = MapControl1.Active.FocusMap就行了,这样就可以得到MapControl1的图层:pMap.Layer(0)</P> |
|
3楼#
发布于:2004-12-14 09:39
<P> 这是我修改后的,编译通过,可是运行时在蓝字处不能通过:</P>
<P> Dim p_App As IApplication <FONT color=#ff0033><FONT style="BACKGROUND-COLOR: #3cc43c"><FONT color=#0000ff>Set p_App = New clsMapHook</FONT></FONT></FONT> </P> <P> Dim pDoc As IMxDocument Set pDoc = p_App.Document Dim pMap As IMap Set pMap = pDoc.FocusMap</P> <P>出现如下错误:</P> <P>"类型不匹配"</P> <P>当我改成如下时:</P> <P> Dim p_App As New clsMapHook Set p_App.MapHook = MapControlMain Dim pDoc As IMxDocument Set pDoc = p_App<FONT color=#0909f7><FONT style="BACKGROUND-COLOR: #2bd52b">.Document</FONT></FONT> </P> <P> Dim pMap As IMap Set pMap = pDoc.FocusMap</P> <P>编译时在上面蓝字处出现错误:“未找到方法或数据成员”。 试了p_App所有的四种属性方法,均行不通。 应该怎样修改?? 苦恼!!! 郁闷中!!!!!</P><img src="images/post/smile/dvbbs/em08.gif" /><img src="images/post/smile/dvbbs/em08.gif" /><img src="images/post/smile/dvbbs/em08.gif" /><img src="images/post/smile/dvbbs/em08.gif" /> [此贴子已经被作者于2004-12-14 9:43:08编辑过]
|
|
4楼#
发布于:2004-12-14 09:31
<FONT size=7>谢谢<b><FONT color=#ff0000>wavvylia</FONT></b> 的热心!</FONT>
|
|
5楼#
发布于:2004-12-14 08:38
hook 是个类模块,它是在某个例子中所附带的,你可以搜搜看。也可以自己写的。它不同于windows中的Hooker函数
|
|
6楼#
发布于:2004-12-13 11:16
<P>那个贴子地址:<a href="http://www.gissky.net/aomo/xm11.asp" target="_blank" >http://www.gissky.net/aomo/xm11.asp</A></P><FONT face=新宋体 color=#000080>Private m_pHook As New Hook 有此一句话,不知Hook是从何而来的。</FONT>
|
|
7楼#
发布于:2004-12-13 10:58
<DIV class=quote><B>以下是引用<I>kidstone</I>在2004-12-13 10:53:44的发言:</B>
好好看看ESRI带的例子</DIV> <P> <P>我知道帮助里有下个例子:</P> <P><FONT color=#000080>Private Sub</FONT> ICommand_OnCreate(<CODE><FONT color=#000080>ByVal</FONT></CODE> <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>hook</FONT> <CODE><FONT color=#000080>As Object</FONT></CODE>) <CODE><FONT color=#000080>Set</FONT></CODE> m_pApp = <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>hook</FONT> <CODE><FONT color=#000080>End Sub</FONT></CODE></P> <P><CODE><FONT color=#000080>但,Private m_pHook As New Hook 这个语句是定义在模块前面的,Hook无法识别。(</FONT></CODE><CODE><FONT color=#000080>我是看一个贴子,把代码copy到VB_Dll中的。) </P></FONT></CODE> |
|
8楼#
发布于:2004-12-13 10:53
好好看看ESRI带的例子
|
|
9楼#
发布于:2004-12-13 10:46
<P>调用Hook,需要在工程中引用什么组件?除了esriCore.olb,还有什么组件?</P><P>我编译时,提示“用户定义类型未定义”。 </P><img src="images/post/smile/dvbbs/em28.gif" />
|
|
上一页
下一页