473,395 Members | 1,948 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,395 software developers and data experts.

Local Mouse Hook problem

I want to intercept mouse events in my application and in certain cases
cancel them. I used the code from CodeProject to implement a mouse hook:

http://www.codeproject.com/csharp/netwin32hooks.asp

(the above code is in C#, but my program is in VB! so this is the right
newsgroup, thank you...)

It works perfectly, and I can intercept the mouse events I want. However, it
doesn't seem like there is no way of cancelling the events (or e.g. setting
handled = true).

Has anybody got experience with that?

Cheers,
Johnny J.

Aug 28 '07 #1
2 2083
>It works perfectly, and I can intercept the mouse events I want. However, it
>doesn't seem like there is no way of cancelling the events (or e.g. setting
handled = true).

Has anybody got experience with that?
You have a WH_MOUSE hook? If so you can skip calling CallNextHookEx
and return nonzero from your hook procedure to prevent the default
message processing, as long as nCode >= 0.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Aug 28 '07 #2
Tack så mycket Mattias - Det var precis det jag ville veta - nu funkar allt
perfekt.

Vänliga hälsningar,
Johnny¨

"Mattias Sjögren" <ma********************@mvps.orgwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
It works perfectly, and I can intercept the mouse events I want. However,
it
doesn't seem like there is no way of cancelling the events (or e.g.
setting
handled = true).

Has anybody got experience with that?

You have a WH_MOUSE hook? If so you can skip calling CallNextHookEx
and return nonzero from your hook procedure to prevent the default
message processing, as long as nCode >= 0.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Aug 31 '07 #3

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

Similar topics

3
by: paul francis | last post by:
Hi Please help because I'm really stuck: I'm trying to write an application in C# which can be used to track the mouse pointer position on any window. I'm trying to use a Global mouse hook to...
9
by: Will Pittenger | last post by:
If I were writing a C++ program, I would write a mouse hook. Does C# and ..NET 1.1 have anything equivalent. If not, I suppose I will need to use the Win32 API. ---------- Will Pittenger...
5
by: Logan Mckinley | last post by:
I need to know where the cursor is (x,y) and when it moves even when it is not over my form. I know i can get the current location with: System.Windows.Forms.Cursor.Position.X...
3
by: june | last post by:
Hi, I am coding for an application with dialog window. I need intercept mouse input. I need catch raw input, pretty much everything for WM_INPUT: such as Left/Middle/Right button down/up,...
6
by: Ahmed | last post by:
Hi, I am trying to capture the mouse events when the user clicks on the desktop not the winform. I looked at the mouse_event function but MSDN documentation says that it is suppressed in win...
3
by: Iosy | last post by:
Hi all, I'm working in a application where I need to detect when the mouse is inactive outside my form. I mean, I want to detect if the mouse hasn't move in the last X seconds (2 por example)...
3
by: harvie wang | last post by:
Hi, I create a system mouse hook, to get mouse position and click events. use GetDesktopWiindow and WindowFromPoint(x,y) to get window handle in my hook proc. Click mouse on desktop window and...
0
by: Johnny J. | last post by:
I want to intercept mouse events in my application and in certain cases cancel them. I used the code from CodeProject to implement a mouse hook: ...
1
by: Tom Rahav | last post by:
Hello, I try to develop application that runs in the background and suppose to display a small form with menu whenever the user clicks the middle mouse button (also when my application is not the...
22
by: schneider | last post by:
I need to hook the system mouse down event. I'm trying to replicate how a context menu hides when the mouse clicks outside of the control. Thanks, Schneider
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.