GetPenInput 

2.0     

Collects data after StartPenInput1AOCU6 has started pen input.

int GetPenInput( HPCM hpcm, LPPOINT lppt, LPVOID lpvOem, UINT fuOemFlags, UINT cPntMax, LPSTROKEINFO lpsi )

Parameters

hpcm

Handle to the current collection. This is the return value from StartPenInput.

lppt

Address of an array of POINT44VP0_ structures. The array must consist of at least cPntMax structures.

lpvOem

The address of a buffer of OEM data associated with each point. This parameter can be NULL if the application does not require OEM data.

fuOemFlags

Flags specifying which OEM data to retrieve. If this parameter is NULL, all OEM data provided by the tablet is returned in the order specified by the rgoempeninfo array in PENINFO3BE5AL5.

These flags have an implicit order. For example, if pressure and barrel rotation are specified, cPntMax pairs of these data are returned, in the order [pressure, rotation], [pressure, rotation], and so on.

Constant

Description

PHW_PRESSURE

Retrieve pressure data.

PHW_HEIGHT

Retrieve height data.

PHW_ANGLEXY

Retrieve data pertaining to the x- and y-coordinates.

PHW_ANGLEZ

Retrieve data pertaining to the z-coordinates.

PHW_BARRELROTATION

Retrieve barrel-rotation data.

PHW_OEMSPECIFIC

Retrieve OEM-specific data.

PHW_PDK

Retrieve per-point PDK_ information in OEM data.

 

cPntMax

The number of POINT44VP0_ structures in the array at lppt. This is the maximum number of points to return and also the maximum number of OEM items the buffer at lpvOem can hold.

lpsi

A pointer to a STROKEINFO1AOCY9 structure. This structure receives information about the first point of the collection of points placed into the array at lppt. The cbPnts member contains the packet ID of the first point. All returned points in the collection have the same tip polarity (that is, up or down) as the first point.

Return Value

Returns 0 if there are no points available. If the return value is positive, the value is the number of points copied to the lppt (and, optionally, lpvOem) buffers. Otherwise, the return value is one of the following:

Constant

Description

PCMR_APPTERMINATED

Input has already terminated because the application called StopPenInput1AOCU8. There are no more points to retrieve.

PCMR_EVENTLOCK

An event must be taken out of the queue using the Windows functions PeekMessage0X9XXX or GetMessageIXKDTP before any more points can be retrieved using GetPenInput.

PCMR_INVALIDCOLLECTION

The hpcm handle is invalid because the calling application did not start input with StartPenInput1AOCU6.

PCMR_TERMTIMEOUT

Input has already terminated because the specified time-out period has elapsed.

PCMR_TERMRANGE

Input has already terminated because the pen has left the range of the tablet s zone of sensitivity.

PCMR_TERMPENUP

Input has already terminated because the pen was lifted from the tablet.

PCMR_TERMEX

Input has already terminated because the pen went down in a specified exclusion rectangle or region.

PCMR_TERMBOUND

Input has already terminated because the pen went down outside a specified bounding rectangle or region.

 

Comments

Once an application initiates pen-input collection by calling StartPenInput1AOCU6, the application then calls the GetPenInput function frequently to retrieve the actual data arriving from the pen device. This can be done by responding to hardware events or by continuously polling.

In the polling model, the application repeatedly calls GetPenInput to get data. It is important for the application to yield periodically; for example, by calling PeekMessage0X9XXX. A fast loop can potentially process the points before the system can collect more. In this case, successive calls to GetPenInput return 0 until the user writes some more. Polling is typically terminated when GetPenInput detects and returns a termination condition specified in StartPenInput.

In the event model, the application calls GetPenInput on receipt of a WM_PENEVENT message. All points up to this event are returned to the caller. An application can retrieve all available data in a short loop, until GetPenInput returns PCMR_EVENTLOCK. The application then falls out of the loop and exits the window procedure. The process begins again when the window procedure is called in response to another WM_PENEVENT message in the application s message queue.

If lpvOem is not NULL, the buffer must be large enough to hold cPntMax OEM data packets. The size of each packet is the width specified in the cbOemData member of the PENINFO3BE5AL5 structure, plus sizeof( UINT ) if PDK_ values are required.

Example

The following code example gathers more pen input for use by the recognizer. Assume the application has already called StartPenInput1AOCU6 and is using the messaging collection model.

POINT      rgPnt[cbBuffer];

STROKEINFO si;

 

// ... in WM_PENEVENT message handler:

 

switch (wParam)

     .

     .

     .

case PE_PENUP:

case PE_PENMOVE:

case PE_TERMINATING:

 

     // Get all the points collected since the last message

 

     while ( (iRet = GetPenInput( hpcm, rgPnt, NULL, 0,

                                                cbBuffer, &si) ) > 0)

    

 

           // Add pen data to recognition context and def process

 

           AddPenInputHRC( vhrc, rgPnt, NULL, 0, &si );

           ProcessHRC( vhrc, PH_DEFAULT );

     }

     break;

 

See Also

PeekPenInput, StartPenInput