如何传递钩子获取的参数? [英] How to pass parameters acquired by hook?

查看:803
本文介绍了如何传递钩子获取的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次开始使用钩子,在将头完全围绕这个概念时遇到了一些麻烦,但是我正在慢慢到达那里.我在Win7-64系统上使用Visual Basic(VS 2008).在高级编译设置中 我已将x86标记为目标CPU.

I'm beginning to work with hooks for the first time and having a little trouble wrapping my head completely around the concept, but I'm slowly getting there.  I'm using visual basic (VS 2008) on a Win7-64 system.  In the advanced compile settings I've ticked x86 as the target CPU.

我设法从http://support.microsoft.com/kb/319524/zh-cn提出了一个示例项目.对不起,超链接...显然我没有得到验证?

I managed to get a sample project to work, lifted from http://support.microsoft.com/kb/319524/en-us.  Sorry about the hyperlink... apparently I'm not verified?

现在,我正尝试通过自定义任务窗格将其集成到现有的可运行MS Word加载项中.我不希望任何外接程序源文档中的所有挂钩过程,因此我添加了一个单独的类,称为"MouseHook". VS项目. 导入必要的名称空间,共享并公开必要的过程和变量等后,我将button_click代码移到了CustomUserControl(任务窗格),并进行了必要的更改以连接到任务窗格上的按钮.注意 任务窗格按钮文本将根据是否切换"hhook.equals(0)"而按预期进行切换.我假设这表明挂钩成功了?

Now, I'm attempting to integrate it into an existing working MS Word Add-in with a custom Task Pane.  I didn't want all the hook procedures in any of the add-in source documents, so I added a separate class called "MouseHook" to the VS project.  After importing necessary namespaces, sharing and making public necessary procedures and variables, etc, I moved the button_click code to the CustomUserControl (Task Pane) and made the necessary changes to connect to a button on the task pane.  Note that the Task Pane button text toggles as intended depending on whether or not the "hhook.equals(0)."  I'm assuming that indicates the hook is successful?

所以,我的问题是,我如何才能将MouseHookProc过程获取的数据检索回外接程序?我尝试使用我"关键字,但intellisense无法识别.我想那是因为程序不是 对象?换句话说,鼠标挂钩过程知道鼠标指针的x/y坐标,并将字符串插入到Form的标题中.在上面链接的示例中,这很好,因为整个示例都以一种形式存在.但, 在我的加载项中,标题不变.

So, my question is this, how can I retrieve the data acquired by the MouseHookProc procedure back to the add-in?  I tried using the "Me" keyword, but intellisense doesn't recognize it.  I suppose that's because the procedure isn't an object?  In other words, the mouse hook procedure knows the x/y coordinates of the mouse pointer and inserts the string into the Form's caption.  That was fine in the example linked above as the entire example resides in a single form.  But, in my Add-in, the caption does not change. 

我想将鼠标位置字符串放在外接程序用户"控件(任务窗格)上的文本框中.如何从Word加载项访问通过挂钩过程获取的数据?

I'd like to put the mouse position string in a textbox on the Add-in User control (Task Pane).  How can I get access to data acquired by the hook procedure from the Word Add-in?




推荐答案

在这里回答:  http://social.msdn.microsoft.com/Forums/vstudio/zh-CN/33e6cb84-ccaa-4fe1-8c60-9f9b9878cfad/how-to-pass-a-parameter-from-a-hook-procedure-to- an-office-addin?forum = officegeneral
Answered here:  http://social.msdn.microsoft.com/Forums/vstudio/en-US/33e6cb84-ccaa-4fe1-8c60-9f9b9878cfad/how-to-pass-a-parameter-from-a-hook-procedure-to-an-office-addin?forum=officegeneral


这篇关于如何传递钩子获取的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆