Hi!

I have problem with system message-handling.
I need to capture mouse and keyboards events in my application. I also
need to know to which window these events refer to. What I can't do is
to modify the application itself.

I tried to use Application.AddMessageFilter method, but I need to call
it in the context of every newly created thread. Is there a way to find
out when new threads are created?

I also tried to use some kind of system hooks. I install procedures
(e.g. JournalRecordProc or GetMsgProc) and use callback function in
managed code. I retrieve some events but after some time an exception is
thrown in my application:

Unhandled Exception: System.NullReferenceException: Object reference not
set to
an instance of an object.
   at System.Windows.Forms.UnsafeNativeMethods.GetMessageW(MSG& msg,
HandleRef h
Wnd, Int32 uMsgFilterMin, Int32 uMsgFilterMax)
   at
System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMet
hods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32
reason, In
t32 pvLoopData)
   at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32
reason, Appli
cationContext context)
   at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
Applicatio
nContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at Test.MyClass.Main(String[] args) in
c:\home\krzycho\test\MyClass.cs:line 30

Does anyone know what can be wrong?

--
Krzysztof Rajda
mailto:[EMAIL PROTECTED]
UIN 63696632 GG 255637
A wise man changes his mind, a fool never will...

Reply via email to