win12.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
WinSendMsg (1.2)
Function Group  Overview                          Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_WINMESSAGEMGR
 
MRESULT WinSendMsg(hwnd, msg, mp1, mp2)
HWND hwnd;     /* handle of the receiving window */
USHORT msg;    /* message                        */
MPARAM mp1;    /* first message parameter        */
MPARAM mp2;    /* second message parameter       */
 
The WinSendMsg function sends a message to the specified window.
 
This function does not return until the message has been processed by the
window procedure. If the window receiving the message belongs to the same
thread, the window function is called immediately as a subroutine. If the
window is of another thread or process, Presentation Manager switches to the
appropriate thread and calls the appropriate window function, passing the
message to the window function. The message is not placed in the destination
thread's queue.
 
Parameter  Description
────────────────────────────────────────────────────────────────────────────
 
hwnd       Identifies the window to send the message to.
 
msg        Specifies the message.
 
mp1        Specifies message parameter 1.
 
mp2        Specifies message parameter 2.
 
Return Value
 
The return value is the result returned by the invoked window procedure.
 
Comments
 
The WM_USER constant marks the beginning of values you can use for your own
messages. For example, you might have a section of a header file that looks
like this:
 
#define WM_USERMSG00  (WM_USER + 0)
#define WM_USERMSG01  (WM_USER + 1)
#define WM_USERMSG02  (WM_USER + 2)
#define WM_USERMSG03  (WM_USER + 3)
 
The following lists some of the differences between WinPostMsg and
WinSendMsg:
 
♦  WinPostMsg returns immediately. WinSendMsg waits for the receiver to
   return.
 
♦  A thread that does not have a message queue can still call WinPostMsg. It
   cannot call WinSendMsg.
 
♦  Calling WinSendMsg to send a message to another thread is costly in terms
   of CPU time. This is not true of WinPostMsg.
 
Example
 
This example gets the window handle of the system menu and calls WinSendMsg
to send a message to disable the Close menu item.
 
HWND hwndSysMenu;
 
hwndSysMenu = WinWindowFromID(hwndDlg, FID_SYSMENU);
WinSendMsg(hwndSysMenu, MM_SETITEMATTR,
    MPFROM2SHORT(SC_CLOSE, TRUE),
    MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED));
 
See Also
 
WinBroadcastMsg, WinPostMsg