Krzysztof, One option you might want to consider is subscribing to the events for all the forms you are trying to monitor from one location. What I mean here is suppose you have a main form which spawns other forms based upon user interaction. You can subscribe to the events of those "child" forms from within the main form. Then you can handle those events in any manner you wish. I've successfully done this when I wanted to detect when a form closed.
Another option would be to create your own custom events and delegates and have those "child" forms raise your custom events. Then in your main form you can subscribe to your custom events and handle as necessary. I hope this helps. Rick McMullen On Wed, 13 Aug 2003 14:52:18 +0200, Krzycho <[EMAIL PROTECTED]> wrote: >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... =================================== This list is hosted by DevelopMentor� http://www.develop.com NEW! ASP.NET courses you may be interested in: 2 Days of ASP.NET, 29 Sept 2003, in Redmond http://www.develop.com/courses/2daspdotnet Guerrilla ASP.NET, 13 Oct 2003, in Boston http://www.develop.com/courses/gaspdotnet View archives and manage your subscription(s) at http://discuss.develop.com
