473,769 Members | 7,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

KeyPress Event & MouseDown event

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
Jul 17 '05 #1
12 24190
On 2 Feb 2004 08:33:48 -0800, MR*******@e-crime.on.ca (Trevor
Fairchild) wrote:

Have you tried Form.KeyPreview ?
Jul 17 '05 #2
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.bt click.com>...
On 2 Feb 2004 08:33:48 -0800, MR*******@e-crime.on.ca (Trevor
Fairchild) wrote:

Have you tried Form.KeyPreview ?

Jul 17 '05 #3
On 3 Feb 2004 05:28:44 -0800, MR*******@e-crime.on.ca (Trevor
Fairchild) wrote:
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.


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$(8) for a start

And annoyinly my version of that control does not have any KeyDown
event
- shifting Focus away from it in the GotFocus event is pretty brutal
- but that might be a solution

Do you really want people to click on the HTML viewer ?
- it sounds not, but I can't be sure

Form.KeyPreview should do exactly what it says on the box
Jul 17 '05 #4
The simple answer is no, I don't want anyone to bother clicking in the
webbrowser, but there's no way for me to actually prevent them from
doing this.

I have already set the WebBrowser1.Got Focus event to automatically
bounce the focus to another control that will handle the keypress
events properly. Unfortunately, this only works if the user
LEFT-clicks with the mouse. a right click sends commands to the
webbrowser itself that supercedes the GotFocus event, for some reason.

I had also thought of the timer, but am concerned about the
performance costs for such a workaround to the subject. The program
is designed for a very fast series of key-press events to cycle
through content of a database (one time trial had me going through
3,000 records in an hour), and as such I'd have to have the timer set
to a pretty high pace in order to make the re-setting of focus
unnoticed by the user - all that for a relatively unlikely, but not
impossible situation.

I have a very simple VBscript function that is hard-coded in the html
pages, that prevents users from right-clicking the html page to get
the standard IE6 options, like view source and Save Picture as, so I
can enter code in that function to inform the user he/she will have to
click somewhere else on the form to use the hot keys again, but that
is kind of hokey and not very professional.

Unforutnately, there isn't even an Enabled or Locked property for the
webbrowser.

That's why I was hoping there was some way of superimposing another
control overtop of the webbrowser - something that could be invisible
but still hijack all attempts to click on the browser.
Jul 17 '05 #5
On 3 Feb 2004 13:17:40 -0800, MR*******@e-crime.on.ca (Trevor
Fairchild) wrote:
<snip>
Unforutnatel y, there isn't even an Enabled or Locked property for the
webbrowser.

That's why I was hoping there was some way of superimposing another
control overtop of the webbrowser - something that could be invisible
but still hijack all attempts to click on the browser.


Hah !

I thought this might be the case

Stick the WebBrowser on a Frame
- and disable the Frame
Jul 17 '05 #6
mwahahahaha, that did it, thanks!
Jul 17 '05 #7
mwahahaha that did it, thanks!
Jul 17 '05 #8
laanbroek
1 New Member
On 3 Feb 2004 13:17:40 -0800, MRTrevorF@e-crime.on.ca (Trevor
Fairchild) wrote:
<snip>
[color=blue]
>Unforutnatel y, there isn't even an Enabled or Locked property for the
>webbrowser.
>
>That's why I was hoping there was some way of superimposing another
>control overtop of the webbrowser - something that could be invisible
>but still hijack all attempts to click on the browser.[/color]

Hah !

I thought this might be the case

Stick the WebBrowser on a Frame
- and disable the Frame
The problem then is that the browser won't react to key up / down, and that it's scrollbars won't work...
Mar 30 '06 #9
Tzargoth
2 New Member
With VB and the IE browser control, you can use a div that is *transparent* and position absolute (adjust z-index as needed) ... either set its width and height to 0 px, place off the visible area, or its z-index to 0 behind everything else; choose which ever you prefer for initial position / state.

Next, create a function in your web page to lock out the user by adjusting the div so that it is in front of everything else (I used a div the size of my page and set its z-index to 3 -- use what works for you). Resize if needed ...

When you want to lock the page, call this lock out function from VB like this:
WebBrowser1.Doc ument.parentWin dow.execScript( "SetLock()" , "JavaScript ")

All left clicks now hit the div and will not affect anything behind it ... Use this html code to block right clicks:

<HTML oncontextmenu=" return false;">

(tested with VB6 and IE6 ... NOTE: users can still select text)
May 31 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1752
by: Plumer | last post by:
Hello everyone, I am using MS .NET Framework 1.0 Version 1.0.3705 developing a C# client application using SQL Server on the server side. I am looking to implement drag & drop in a TreeView control. The operation takes place entirely within this single control. There is no need to provide for interaction with other controls, forms, applications etc. Both the drag source item (a TreeNode) and the drag target item (another TreeNode) are...
2
16320
by: JJ | last post by:
Hi All, I need to create a MouseDown event for a picture box . Am I doing the following right? pictureBox.MouseDown += new System.WinForms.MouseEventHandler(pictureBox_MouseDown) Then
4
4741
by: rsmith | last post by:
How can I capture the MouseDown event on a Label ? I entered thr following code and got a " cannot handle Event 'MouseDown' because they do not have the same signature." Private Sub Label1_MouseDown _ (ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles Label1.MouseDown
4
4533
by: Tom | last post by:
I have a VB.NET user control that I wrote - this control has three or four other controls on it (textbox, combobox, datetime picker, etc). Now, whenever the control is on a form and the user enters anything into the textbox (for instance) I trap the keypress event to handle some stuff (i.e. if it is an enter key, etc). Now, once I am done with handling the keypress event for the textbox, I then need to pass that keypress event BACK to the...
15
4055
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE CALLING FORM! This is very bad for me, because in my application, Form1 responds to an ENTER keypress by calling Form2. If the user closes Form2 via an ENTER, then Form1 just reopens it again, kind of trapping the user in Form2 (they can still close...
3
6864
by: Fia | last post by:
Hi In Visual Basic 6 I could call keypress with an integer of a choosen key. For example I could call a textbox's keypress with the number 13 (for the enter key). But now in Visual Basic .Net I don't know how I shall do to do the same thing. I have tried to send Keys.Numpad8, but then it complains about it cannot convert from Keys to keyEventArgs I have also tried to send the number 8, but then it complains it cannot convert from Integer...
5
8899
by: Steve | last post by:
In VB6 I have a screen the has a text box and a datagrid If I click the datagrid, the 1st event is to validate the textbox and then the 2nd event is a datagrid mousedown event. If a get an error message in the textbox validate it seems the mousedown event is never executed. In VB.Net it executes the textbox validation and then displays the error, but still executes the mousedown event. It appears that I have to explicitly...
4
2098
by: khalid galal | last post by:
Hi, i am having a problem with removing event handlers, it is when creating nested event handlers (an event handler raising another event handler) where a part of the code is private void toolStripButton1_Click(object sender, EventArgs e) { this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_ MouseDown); } private void Form1_MouseDown(object sender, MouseEventArgs e) { this.MouseUp += new...
2
7716
by: svibuk | last post by:
i have a asp.net list box populated with databae data , autopostback = true wht i need is 1) when double clicked(double click event) i want it to be visible=false 2)i want to move between the data in the listbox using up, down arrow keys & make the selection by pressing eneter(keypress event) 3) everytime i move betwen the data(autopostback = true) postback is caused,is it possible to avoid the flickering without ajax as if i have to...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10048
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.