KeyPress活动& MouseDown事件 [英] KeyPress Event & MouseDown event

查看:69
本文介绍了KeyPress活动& MouseDown事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序,专为使用键盘上的

特定按钮进行快速导航而设计。在这样做的过程中,我为表单上的每个控件添加了一个

的KeyPress事件,以拦截按下的键

并将其传递给标识子程序,该子程序标识了什么

应该采取行动。


不幸的是,我在表单上有一个网络浏览器控件和

webbrowser不包含KeyPress事件。


我需要一些方法来拦截

webbrowser的按键和mousedown事件 - 我的想法是把一个控件放在这个事件上/>
webbrowser的顶部,但我一直无法找到一个控件,

可以透明,同时也可以放在webbrowser的顶部 -

imagebox控件将是透明的,但由于某种原因它总是

落后于webbrowser,即使我强行将它推到前面。


我的第二个想法是在我在webbrowser中显示的html页面中的

陷阱按键和鼠标点击事件然后传递

他们和vb一起 - 但我没有丝毫的线索如何做到这一点,

或者即使它可以完成。

有没有人对这个问题有任何想法?


任何帮助都会受到赞赏。


谢谢。


Trevor Fairchild

I''m writing a program that is designed for quick navigation using
specific buttons on the keyboard. In doing this, I have added a
KeyPress event for every control on the form to intercept the key
pressed and pass it to a standard subroutine that identifies what
action should be taken.

Unfortunately, I have a web-browser contol on the form and the
webbrowser does not include a KeyPress event.

I need some way to intercept keypress and mousedown events for the
webbrowser - my thought was to put a control that has these events on
top of the webbrowser, but I have been unable to find a control that
can be transparent while also sitting on top of a webbrowser - the
imagebox control will be transparent, but for some reason it always
falls behind the webbrowser even when I force it to the Front.

my second thought is to trap key press and mouse click events from
within the html pages I am showing in the webbrowser and then passing
them along to vb - but I don''t have the slightest clue how to do that,
or even if it can be done.

Does anyone have any ideas on a soltion to this problem?

any help would be appreciated.

thanks.

Trevor Fairchild

推荐答案

2004年2月2日08:33:48 -0800, MR ******* @ e-crime.on.ca (Trevor

Fairchild)写道:


你有没有尝试过Form.KeyPreview?
On 2 Feb 2004 08:33:48 -0800, MR*******@e-crime.on.ca (Trevor
Fairchild) wrote:

Have you tried Form.KeyPreview ?


其实我从来没有听说过KeyPreview。它使我的代码很多

更紧凑,但遗憾的是,经过一些测试后,当webbrowser处于焦点时,它不会影响按键事件。


目前,我已经陷入了网页浏览器的Got Focus事件,

将其重定向到另一个控件,但这只适用于用户

在Web浏览器中单击鼠标左键;右键单击发送命令到

webbrowser,而不是劫持回VB6。


我有一些写入html的VBScript页面

禁用您通常在网页中获得的下拉菜单。


我能想到的唯一解决方法是放置

VBScript函数中的msgbox命令警告用户他/她必须在表单中的其他位置单击

才能再次使用热键。
er*****@nowhere.com (法语J)在留言中写道:< 40 **** ********** @ news.btclick.com> ...
Actually I''d never even heard of KeyPreview. It makes my code a lot
more compact, but unfortunately, after some testing, it does not
affect keypress events when the webbrowser is in focus.

For the moment, I have trapped the Got Focus event of the webbrowser,
redirecting it to another control, but this only works if the user
left-clicks in the webbrowser; a right-click sends commands to the
webbrowser than I cannot hijack back to VB6.

I''ve got some VBScript that is written into the html page that
disables the drop-down menu that you''d normally get in a web page.

The only workaround I can think of is to put a msgbox command in the
VBScript function alerting the user that he/she will have to click
elsewhere in the form in order to use the hot keys again.
er*****@nowhere.com (J French) wrote in message news:<40**************@news.btclick.com>...
2004年2月2日08:33:48 -0800, MR ******* @ e-crime.on.ca (Trevor
Fairchild)写道:
<你有没有尝试过Form.KeyPreview?
On 2 Feb 2004 08:33:48 -0800, MR*******@e-crime.on.ca (Trevor
Fairchild) wrote:

Have you tried Form.KeyPreview ?



2004年2月3日05:28:44 -0800, MR ******* @ e-crime.on.ca (Trev或者

Fairchild)写道:
On 3 Feb 2004 05:28:44 -0800, MR*******@e-crime.on.ca (Trevor
Fairchild) wrote:
其实我甚至都没听说过KeyPreview。它使我的代码更加紧凑,但不幸的是,经过一些测试后,当webbrowser成为焦点时,它不会影响按键事件。

目前,我已经陷入了网页浏览器的Got Focus事件,
将其重定向到另一个控件,但只有当用户在网页浏览器中左键单击时才有效;右键单击发送命令到
webbrowser,而不是劫持回VB6。

我有一些写入html页面的VBScript,
禁用了您通常会在网页中获得的下拉菜单。

我能想到的唯一解决方法是在
VBScript函数中添加msgbox命令,提醒用户他/她将不得不点击表格中的其他地方再次使用热键。
Actually I''d never even heard of KeyPreview. It makes my code a lot
more compact, but unfortunately, after some testing, it does not
affect keypress events when the webbrowser is in focus.

For the moment, I have trapped the Got Focus event of the webbrowser,
redirecting it to another control, but this only works if the user
left-clicks in the webbrowser; a right-click sends commands to the
webbrowser than I cannot hijack back to VB6.

I''ve got some VBScript that is written into the html page that
disables the drop-down menu that you''d normally get in a web page.

The only workaround I can think of is to put a msgbox command in the
VBScript function alerting the user that he/she will have to click
elsewhere in the form in order to use the hot keys again.




这听起来很可怕


我没有使用MS webbrowser控件所以我的建议只能是

''理论''


听起来好像你不要特别希望Webbrowser拥有

焦点...所以你可以使用它的GotFocus事件把它拿回来

- 甚至是一个计时器

假设您正在使用Microsoft Internet Controls - WebBrowser1

- 它看起来好像是在它/表单获取之前窃取某些键/

th e KeyDown活动


- [F5]和Chr



That sounds horrible

I don''t use the MS webbrowser control so my suggestions can only be
''theoretical''

It sounds as if you do not particularly want the Webbrowser to have
focus ... so you could grab it back using its GotFocus event
- or even a Timer

Assuming you are using Microsoft Internet Controls - WebBrowser1
- it looks as if it steals certain keys /before/ the Form gets them in
the KeyDown Event

- [F5] and Chr


这篇关于KeyPress活动&amp; MouseDown事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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