Jump to content

ThunkProc

From EDM2
Revision as of 19:43, 13 April 2025 by Martini (talk | contribs) (Created page with "This procedure provides pointer conversion for application-defined messages. ==Syntax== ThunkProc(hwnd, usmsg, mpParam1, mpParam2, pWndProc); ==Parameters== ;''hwnd'' (HWND) - input: Window handle. ;''usmsg'' (USHORT) - input: Message identity. :This is an application-defined message. The value is greater than or equal to WM_USER. ;''mpParam1'' (MPARAM) - input: Message parameter 1. ;''mpParam2'' (MPARAM) - input: Message parameter 2. ;''pWndProc'' (PFNWP) - input: Wi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This procedure provides pointer conversion for application-defined messages.

Syntax

ThunkProc(hwnd, usmsg, mpParam1, mpParam2, pWndProc);

Parameters

hwnd (HWND) - input
Window handle.
usmsg (USHORT) - input
Message identity.
This is an application-defined message. The value is greater than or equal to WM_USER.
mpParam1 (MPARAM) - input
Message parameter 1.
mpParam2 (MPARAM) - input
Message parameter 2.
pWndProc (PFNWP) - input
Window-procedure identifier.

Returns

mresReply (MRESULT) - returns
Message-return data.

Remarks

Pointer conversion is normally performed automatically by the operating system. An application needs to provide its own pointer-conversion procedures only for application-defined messages which may be passed from 16-bit code to 32-bit code.

A pointer-conversion procedure is associated with a window by the WinSetWindowThunkProc and WinSetClassThunkProc functions.

The logic of the pointer-conversion procedure is as follows:

  1. Convert each message parameter, if necessary. This may include converting any data structures to which the parameter points.
  2. Call the window procedure referenced by the pWndProc parameter, supplying as arguments hwnd, usmsg, mpParam1 and mpParam2.
  3. Collect the return value and, if necessary, convert it. Note that structures to which the return value might point cannot be converted.
  4. Convert any structures referenced by message parameters which might have been modified by the window procedure. Note that the pointer-conversion procedure should ensure that the original memory is still available before converting the structures.

A pointer-conversion procedure should process only those messages that it recognizes. On receiving unrecognized messages, it should set usmsg to 0.

Example Code

#define INCL_NONE
#include <os2.h>

HWND    hwnd;       /* Window handle. /
USHORT  usmsg;      / Message identity. /
MPARAM  mpParam1;   / Message parameter 1. /
MPARAM  mpParam2;   / Message parameter 2. /
PFNWP   pWndProc;   / Window-procedure identifier. /
MRESULT mresReply;  / Message-return data. */

mresReply = ThunkProc(hwnd, usmsg, mpParam1, mpParam2, pWndProc);