This example uses the WinSetClassMsgInterest call to set the message interest of window class WC_MENU. It allows one to process the messages of this window class in the MsgControlHook procedure.

#define INCL_WINMESSAGEMGR
#define INCL_WINHOOKS
#define INCL_WINMENUS    /* for WC_MENU parameter definition. */
#include <OS2.H>
main()
{
   /* Hook Procedure Prototype */

BOOL MsgControlHook(HAB hab,LONG  idContext,    /* this hook can */
               HWND hwnd, PSZ pszClassname,     /* be given any */
               ULONG  ulMsgclass,               /* name.        */
               LONG  idControl, PBOOL fSuccess);
HWND hwnd;
HAB hab;
BOOL fSuccess;


/* This function passes the hook procedure address to the system. */

WinSetHook(hab,
          (HMQ)0,
          MCHK_CLASSMSGINTEREST,
          (PFN)MsgControlHook,
          (HMODULE)0); /* hook is into application queue. */

 /*
 This function sets the message interest of a window class.
 */
WinSetClassMsgInterest(hab,
                       WC_MENU,  /* menu window class.         */
                       SMIM_ALL, /* set interest level for all */
                                 /* messages.                  */
                       SMI_AUTODISPATCH); /* interested in the */
                                 /* messages, but they are to  */
                                 /* be automatically dispatched */
                                 /* to the window procedure.    */
}
/*
 This hook allows the call which determine the flow of messages to be
 intercepted. It must be present for the WinSetClassMsgInterest
 call to have an effect.
*/

BOOL MsgControlHook(HAB hab,LONG  idContext,    /* this hook can */
               HWND hwnd, PSZ pszClassname,     /* be given any */
               ULONG  ulMsgclass,               /* name.        */
               LONG  idControl, PBOOL fSuccess)
{
/* ... */
}


[Back] [Next]