Trapping Windows Messages

Luke Gardiner

New Member
Hello All,
I'm attempting to trap for various messages that gets sent to a progress window, such as the window has been moved (WM_MOVE). Other posts suggest using the Msgblst32 OCX, however it appears that only some of the messages get through such as the when the middle mouse button is scrolled. Put the OCX into a Delphi form however and everything works fine.

Other attempts have included writing my own msgblst in VB or Delphi, without much luck. The only attempt that worked was using a timer and various calls to the WinAPI to build my own "triggers", one for when the window starts to move and one for when it stops, however having that timer interrupting constantly was a huge drawback for a small feature.

Now my understanding of the OCX is that it uses the SetWindowLong WinAPI function with the GWL_WNDPROC flag to change the procedure to which the messages are sent. I've tried making a SetWindowLong call from a 4GL process but get bogged down when it comes to entering the address of the procedure to replace the old one. Anyone know how to obtain the address of a procedure that windows will understand, or have any other suggestions for intercepting windows messages, before progress gets a hold of em.

Thanks

P.S. I read somewhere that Delphi has a "hidden window" that receives the win msg's and passes them onto the a "visible one". Any chance that progress has one too and hence the WINDOW-NAME:hWND used with the OCX, is not actually the one to which the messages are sent?

Luke Gardiner
Systems Officer
Dental Health Services
Luke.Gardiner@dental.health.wa.gov.au
 
How to Trap for ANY Windows Messages

Yes! I have managed to write the ultimate Msgblst32 OCX that traps/intercepts ANY windows message sent to a progress (or any application for that matter) application, whether its a keyboard, mouse, windows or dialog event to name a few. The OCX was written using Delphi7 and centres around the SetWindowsHookEx Windows API function, which basically "hooks" any windows messages sent to a thread. This is techniqure known as "subclassing", is the basis behind spyware and keyloggers.
What I found most amazing is that my OCX (codenamed MsgBlasterific) similar to the MsgBlst32, only requires a handle to a window and the messages to look out for, however since it uses the window handle to get a thread handle, it can watch out for any message sent to a window that was created by the same thread.
Its still in the beta stage at the moment, therefore only listening, however theoretically its possible to next start handling or even changing some of these messages, potentially leading onto some very interesting use's, such as eliminating allowable keystrokes in fill-ins, to changing the function of mouse clicks!

The following two URL's helped me immensely in this project.

http://www.undu.com/Articles/980415b.htm

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp

Happy Hooking.

Luke Gardiner
Systems Officer
Dental Health Service
 
Back
Top