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 structure. (Note that lParam is a pointer to a pointer.)

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 DefWindowProc function enumerates all the descendants of the window specified in its first parameter and sends each one a PE_GETPCMINFO message. For every descendant that returns 1 to this message, the PCM_RECTBOUND and PCM_RECTEXCLUDE flags of the PCMINFO structure are examined. If the PCM_RECTBOUND flag is set, the descendant is included in the list of potential targets and the rectBound member in PCMINFO is copied to the rectBound member of the TARGET 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. A PE_GETPCMINFO message will follow to establish targets or termination conditions (buttons, for example).

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 structure plus all the TARGET structures.

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 npics/PENAPI00090000.gif1 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

PCMINFO
, TARGET, TARGINFO, WM_PENEVENT

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database