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

Reading window messages of another thread

Hi there,

I realize this is more of a Windows API question then C#, but thought
I'd ask anyway just in case anyone had experience with this specifically
in C#. What I'm trying to do is read window messages for windows that
aren't owned by current thread. That's the key part because if I just
wanted to read messages for my own windows I'd just use the GetMessage
function from user32.dll.

I have no problems finding the window I'm looking for, but if I call
GetMessage with that window's handle, all it does is just sit there and
never return a thing. For those of you who have used Spy++ you know that
it's possible to just read the messages of any random window. My
question is how would I be able to do this from my app. I've looked
through the MSDN docs on this topic, but any function that would let me
read messages always states that it has to be for the window owned by
current thread.

Any ideas on a way around that? Thanks.
Nov 17 '05 #1
1 1652
The standard way of doing this in Win32 is to use SetWindowsHookEx with the
WH_GETMESSAGE and WH_CALLWNDPROC filters. I believe Spy uses this API. The
source code for Spy is in the SDK and therefore you can dump the code to
determine how to do it. There is no .NET equivalent for arbitrary windows.
For your own windows you can just overload the window procedure and raise an
event but it would dramatically slow things down. Refer to "Win32 Hooks" in
MSDN for more info on SetWindowsHookEx.

Michael Taylor - 7/3/05

"Max Khitrov" wrote:
Hi there,

I realize this is more of a Windows API question then C#, but thought
I'd ask anyway just in case anyone had experience with this specifically
in C#. What I'm trying to do is read window messages for windows that
aren't owned by current thread. That's the key part because if I just
wanted to read messages for my own windows I'd just use the GetMessage
function from user32.dll.

I have no problems finding the window I'm looking for, but if I call
GetMessage with that window's handle, all it does is just sit there and
never return a thing. For those of you who have used Spy++ you know that
it's possible to just read the messages of any random window. My
question is how would I be able to do this from my app. I've looked
through the MSDN docs on this topic, but any function that would let me
read messages always states that it has to be for the window owned by
current thread.

Any ideas on a way around that? Thanks.

Nov 17 '05 #2

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

Similar topics

5
by: Claire | last post by:
My progress window is created by a secondary thread and then updated by it while a file is uploaded. There's an avi animation control on there that should show the move file avi. Plus a progress...
11
by: objectref | last post by:
Hi to all, is there a way to get the window handle of the main window of an application or process ? For example, if someone opens Microsoft Word, he gets a window so he/she can write text....
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
0
by: sam | last post by:
Hi, Im using windows froms exe application to read and send messages to private message queues. Using threads how can I keep reading all the messages from MS private message queuing without...
0
by: chathurangakw | last post by:
Hi , I'm working on a smart client application. In one of my forms I have a socket instance which listens for any messages from others and there are some other windows forms too. when the...
14
by: | last post by:
Hi All, I am little confused here, hope you can help me. While processing WM_POWERBROADCAST (wParam=PBT_APMQUERYSUSPEND), I MUST to do some lengthy operation(30 sec) before system Suspends or...
0
by: Manfred Braun | last post by:
Hi All, I have a problem reading queue-messages async. My QueueReader has a Start() and a Stop() method and if my app starts, it calls Start(). The problem is, that there are possibly several...
16
by: MLH | last post by:
If I give someone a runtime app, they can open the database window by pressing the F-11 key. How to prevent???
1
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a C# application in which I start another process which produces output to stdout and stderr. In fact, that process is the uSoft VS2005 C/C++ compiler itself! I would like to...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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...

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.