TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Daniel Doran
from: Johan Siegers
date: 1995-11-14 09:56:38
subject: WinSetHook()

Hi Daniel,

 DD> Does anyone have a working example of using hooks with WinSetHook(),
 DD> particularly for input or journal hooks (HK_INPUT,
 DD> HK_JOURNALRECORDHOOK, HK_JOURNALPLAYBACKHOOK).

I use a hook to be notified if the mouse is moved, even if not my main
application is on top, but other programs which I DosSubStart()
In this example the use has been simplied to a beep.
The hook procedure is in a dll.

In my main program:
   HMODULE ModuleHandle;   

   DosQueryModuleHandle("mydll.dll",&ModuleHandle);
   WinSetHook(hab, NULLHANDLE, HK_INPUT, (PFN)RecordHook, ModuleHandle);

In Mydll.dll
 BOOL _export EXPENTRY RecordHook(HAB hab, PQMSG pqmsg, USHORT fs)
 {
  
   if(pqmsg->msg == WM_MOUSEMOVE)
   {
       DosBeep(1000,50);
   }
   return(FALSE);   // Operation has ended, so originator may continue
 }

Please note that the EXPENTRY in the hook procedure is vital, although even
borland's examples are without !


Bye, Johan.

--- The-Box Point 0.15+ PC
* Origin: johan{at}bitbike.iaf.nl - CIS: 100120,2502 (2:283/512.16)
SEEN-BY: 270/101 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 712/515 517 628 713/888 800/1 7877/2809
@PATH: 283/512 280/801 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.