PE_SETTARGETS
Sent to an application
window so that it can set its own targeting structure. Submessage of
WM_PENEVENT.
Parameters
wParam
PE_SETTARGETS.
lParam
Address of a
far pointer to a TARGINFO
Return Value
The application
should return LRET_DONE to indicate that it has set up the targeting
information for the child windows. A return of 0 indicates that the application
is the only target. The application can also return LRET_ABORT to abort the
targeting process altogether.
Comments
The DefWindowProc1AOCY_ structure. If the PCM_RECTEXCLUDE flag is
set, the rectExclude member of PCMINFO is added to an exclusion
region that is passed (as the hrgnExclude member of the PCMINFO
structure) to the StartInput call. If there are no descendants, or if
the window procedure of hwnd returns 0, a TARGINFO structure is
constructed with hwnd as the single target.
For default
processing behavior, the application should allow PE_SETTARGETS to fall through
to DefWindowProc
For further
information about PE_SETTARGETS, see Chapter 2, Starting Out with System Defaults.
An
application can replace the default targeting with a set of targets it defines
itself. In this case, the application allocates enough memory for the TARGINFO
Example
The following
example illustrates how to handle PW_SETTARGETS for n targets, where
each target is in the array rgHwnd. Notice the code increases the
allocation by n-1 TARGET
structures, since TARGINFO already contains one TARGET structure.
DWORD cbAlloc
= sizeof(TARGINFO) + (n-1) * sizeof(TARGET);
HGLOBAL hTargets
= GlobalAlloc( GHND, cbAlloc );
LPTARGINFO lptarginfo = GlobalLock( hTargets );
lptarginfo->cbSize = sizeof(TARGINFO);
lptarginfo->cTargets = n; // Number of targets
lptarginfo->htrgOwner = HtrgFromHwnd(hwnd); // Macro in penwin.h
lptarginfo->dwFlags = TPT_TEXTUAL; // For text
for (i = 0; i < n; i++)
{
HWND hwnd
= (HTRG)rgHwnd[i]; // Window
of this target
lptarginfo->rgTarget[i].dwFlags = 0; //
Reserved
lptarginfo->rgTarget[i].idTarget = i;
lptarginfo->rgTarget[i].htrgTarget
= HtrgFromHwnd(hwnd);
lptarginfo->rgTarget[i].dwData
= 0;
// Use
screen coords of each window:
{
// Note: rectBound is a RECTL. In 16-bit code, one
has to assign each
// field separately. In 32-bit code, you can use the
rectBound directly.
RECT rect;
GetClientRect(
hwnd, &rect);
ClientToScreen(
hwnd, (LPPOINT)&rectBound.left);
ClientToScreen(
hwnd, (LPPOINT)&rectBound.right);
lptarginfo->rgTarget[i].rectBound.left = rect.left;
lptarginfo->rgTarget[i].rectBound.top = rect.top;
lptarginfo->rgTarget[i].rectBound.right = rect.right;
lptarginfo->rgTarget[i].rectBound.bottom = rect.bottom;
}
}
// Return our structures:
*(LPTARGINFO FAR *)lParam = lptarginfo;
See Also