473,327 Members | 2,016 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,327 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 2075
>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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.