WinSetMsgInterest
Appearance
This function sets a window's message interest.
Syntax
WinSetMsgInterest(hwnd, ulMsgClass, lControl)
Parameters
- hwnd (HWND) - Input
- Window handle.
- 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_RESET
- Revert to the interest specified for the window class.
- SMI_INTEREST
- Interested in the messages.
- SMI_NOINTEREST
- Not interested in the messages.
- 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> HWND hwnd; /* Window handle. */ ULONG ulMsgClass; /* Message class to have interest level set. */ LONG lControl; /* Interest-identifier for the message class. */ BOOL rc; /* Interest-changed indicator. */ rc = WinSetMsgInterest(hwnd, ulMsgClass, lControl);
This example sets the message interest of a window to only WM_SHOW messages.
#define INCL_WINMESSAGEMGR #define INCL_WINHOOKS #include <OS2.H> HWND hwnd; HAB hab; BOOL fSuccess; /* Hook Procedure Prototype */ BOOL MsgCtlHook(HAB hab,LONG idContext, /* this hook can */ HWND hwnd, PSZ pszClassname, /* be given any */ ULONG ulMsgclass, /* name. */ LONG idControl, PBOOL fSuccess); main() { /* This function passes the hook procedure address to the system. */ WinSetHook(hab, (HMQ)0, MCHK_CLASSMSGINTEREST, (PFN)MsgCtlHook, (HMODULE)0); /* hook is into application queue. */ /* This function sets the message interest of a window class. */ WinSetMsgInterest(hwnd, WM_SHOW, SMI_AUTODISPATCH); /* interested in the */ /* messages, but they are to */ /* be automatically dispatched */ /* to the window procedure. */ } BOOL MsgCtlHook(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
- WinSetClassMsgInterest
- WinSetMsgMode
- WinSetSynchroMode
- WinWaitMsg