WinSetClassMsgInterest
Appearance
This function sets the message interest of a window class.
Syntax
WinSetClassMsgInterest(hab, pszClassName, ulMsgClass, lControl)
Parameters
- hab (HAB) - Input
- Anchor-block handle.
- pszClassName (PSZ) - Input
- Window-class name.
- ulMsgClass (ULONG) - Input
- Message class to set interest for. Can be a specific message ID (e.g., WM_SHOW) or SMIM_ALL (all messages except WM_QUIT under certain lControl values).
- lControl (LONG) - Input
- Interest identifier.
- SMI_INTEREST
- Interested in the message(s).
- SMI_NOINTEREST
- Not interested in the message(s).
- SMI_AUTODISPATCH
- Interested, but messages should be automatically dispatched to the window procedure.
- rc (BOOL) - Returns
- TRUE if interest was successfully changed, FALSE otherwise.
Returns
- rc (BOOL) - returns
- Interest-changed indicator.
- TRUE
- Interest successfully changed
- FALSE
- Interest not successfully changed.
Remarks
This function only works if the MsgControlHook hook has been set.
The interest for WM_QUIT cannot be set to SMI_AUTODISPATCH using SMIM_ALL, as WM_QUIT is the standard way to terminate an application. It can be set specifically if needed.
Errors
Possible returns from WinGetLastError:
- PMERR_INVALID_HWND (0x1001) - An invalid window handle was specified.
Example Code
#define INCL_WINMESSAGEMGR /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>
HAB hab; /* Anchor-block handle. */
PSZ pszClassName; /* Window-class name. */
ULONG ulMsgClass; /* Message class to have interest level set. */
LONG lControl; /* Interest identifier for the message class. */
BOOL rc; /* Interest-changed indicator. */
rc = WinSetClassMsgInterest(hab, pszClassName,
ulMsgClass, lControl);
This example sets the message interest for the WC_MENU window class, allowing its messages to be processed 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)
{
/* ... */
}
Related Messages
Related Functions
- WinBroadcastMsg
- WinCreateMsgQueue
- WinDestroyMsgQueue
- WinDispatchMsg
- WinGetDlgMsg
- WinGetMsg
- WinInSendMsg
- WinPeekMsg
- WinPostMsg
- WinPostQueueMsg
- WinQueryMsgPos
- WinQueryMsgTime
- WinQueryQueueInfo
- WinQueryQueueStatus
- WinSendDlgItemMsg
- WinSendMsg
- WinSetMsgInterest
- WinSetMsgMode
- WinSetSynchroMode
- WinWaitMsg