473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to create ( not handle) a mouse/keyboard event ?

Hi All,

We can process the mouse/keyboard events by handling, however, how to
create a event on a target form ( ex: webbrowser ) ?

Thanks!

Best regards,
Boki.

Jun 28 '07 #1
2 2830
"Boki" <bo******@ms21.hinet.netwrote in message
news:11*********************@o11g2000prd.googlegro ups.com...
We can process the mouse/keyboard events by handling, however, how to
create a event on a target form ( ex: webbrowser ) ?
You create an event inside any class, which includes a form if that is
what you wish. Any consumer referencing your class can then handle the
events that are fired by your class.

Creating the event in C# is a two-step process: You create a delegate
with the type of the event and then you create the event itself:

public delegate void MyEventHandler(object sender, EventArgs e);
public event MyEventHandler MyEvent;

Now you have to decide under which conditions you want to raise that
event. When those conditions are met in your class you raise the event by
calling it:

if (mycondition)
{
if (MyEvent!=null) MyEvent(this, EventArgs.Empty);
}

Notice the check for a null condition. This is to avoid an error in case
no one has subscribed to the event.
Notice also that we included two arguments, 'sender' and 'e'. This
follows the pattern that Microsoft established for all the events in the
Framework, but it is not a requirement for the event to work. You can define
events with any combination of arguments.

Jun 28 '07 #2
Did you look at http://msdn2.microsoft.com/en-us/library/ms171548.aspx
?
"Boki" <bo******@ms21.hinet.netwrote in message
news:11*********************@o11g2000prd.googlegro ups.com...
Hi All,

We can process the mouse/keyboard events by handling, however, how to
create a event on a target form ( ex: webbrowser ) ?

Thanks!

Best regards,
Boki.


Jun 28 '07 #3

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

Similar topics

1
by: Michael J Whitmore | last post by:
Greetings, I have a very simple question. How do you simulate a user input to turn off a screen saver in Windows (either a mouse movement, mouse click, or keyboard input)? I promise I searched...
2
by: Carl Gilbert | last post by:
Hi I have a basic page for which I have included some of the code for at the end of this message. It may not run correctly as I have cropped out a lot of code. I am trying to handle the...
3
by: Lachlan Hunt | last post by:
Hi, I've been looking up lots of documentation and trying to work out a cross-platform method of capturing a keyboard event and working out which key was pressed. From what I can find, there...
4
by: ML | last post by:
I am trying to use the mouse wheel event on a numeric input box to allow the use to scroll to inc/dec the value by 1. The issue I am having is that the delta value returned seems to be off. From...
1
by: MrNobody | last post by:
What kind of wizardry do I have to pull off so I can capture a mouse click event or a key press event from OUTSIDE my form? Ideally, with either case I also consume the event so that it does not...
0
by: skip | last post by:
Sorry to bomb this list with an off-topic post, however... Ages ago I wrote a mouse/keyboard watcher in Python+Tk: http://sf.net/projects/watch. It's been idle for a long while though, isn't...
1
by: =?Utf-8?B?TXJOb2JvZHk=?= | last post by:
I want to do something similar to what some macro tools do, where they perform mouse/keyboard events on the user's machine , while intercepting the user's current keyboard/mouse events so that it...
3
by: pfm721 | last post by:
I know the control tip text will display information about a text box. However I was wondering if there is a way to change it based on the value of the text box. Is it possible to create a mouse...
4
by: shariquekhan | last post by:
Hi, I am using windows forms. I have a problem in handling mouse events. In my application there is menu bar on top. In menu bar I have several toolstripmenu items. I want that when toolstripmenu...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.