Creates a HPENDATA
object from serial data in a buffer. The buffer must have been previously
written by the PenDataToBuffer
LONG PenDataFromBuffer( LPHPENDATA lphpndt, UINT gmemFlags, LPBYTE lpBuffer, LONG cbBuf, LPDWORD lpdwState )
Pointer to an uninitialized HPENDATA
handle. If PenDataFromBuffer
returns successfully, lphpndt
points to a new HPENDATA
object containing a copy of the serial points.
Flag that specifies whether or not the Windows GlobalAlloc
function should create a shared memory object when the pen data object is
created. This should be either 0 or GMEM_DDESHARE. The GMEM_MOVEABLE and
GMEM_ZEROINIT flags are added to this value and other GMEM_ flags are ignored.
Pointer to a byte buffer containing serial data.
Size of the buffer, which must be at least 64 bytes in size. If the buffer
serves as an intermediate holding area, it need not be as large as the final HPENDATA
object. To create the object, the application must call PenDataFromBuffer
successively, each time reading a new section of data into the buffer that lpBuffer
points to before the call. The example below illustrates this technique by
filling an HPENDATA
object in stages, reading data from a file in cbBuf
Address of a DWORD variable used by the system to maintain the transfer state.
The DWORD variable must be initialized to 0 before the first call to PenDataFromBuffer
. Between successive calls to PenDataFromBuffer
, the application must not alter the value that lpdwState
points to. lpdwState
can be NULL to signify that the buffer contains the entire data set for the HPENDATA
object. This implies that subsequent calls to PenDataFromBuffer
are not necessary.
If successful, PenDataFromBuffer
returns the number of bytes transferred from the buffer. If the size of the
pen data is larger than the buffer, the return value is equal to the buffer size
passed in cbBuf
. A value of 0 indicates no more data to transfer. If there is an error, one
of the following negative values is returned:
||Parameter or overflow error.
The data being provided by the application must have been previously written
by the PenDataToBuffer
function. The application cannot modify this data in any way. Embedded values
within the first 64 bytes provide information to PenDataFromBuffer
about the size of the pen data.
creates an HPENDATA
object and provides a handle to it. The application must destroy the object
when finished. The lphpndt
argument points to a valid HPENDATA
handle only if the function returns PDR_OK.
While this function is reconstituting the HPENDATA
object, the application must not attempt to use it in any way because it will
be invalid until the last buffer is read.
The following example shows how to create a HPENDATA
object from a file (hfile
) that has already been opened for reading. Before reading the pen data, its
length is retrieved from the file:
#define cbBufMax 1024
HPENDATA NEAR PASCAL ReadPenData( HFILE hfile )
HPENDATA hpndt = NULL;
LONG cb, cbRead, cbHpndt;
BYTE lpbBuf[cbBufMax]; // Buffer
DWORD dwState = 0L; // Must initialize to 0
|| (cb = _lread(hfile, &cbHpndt, sizeof(DWORD))) == HFILE_ERROR
|| cb != sizeof(LONG))
while (cbHpndt > 0)
if ((cbRead = _lread( hfile, lpbBuf, min(cbHpndt, cbBufMax )))
|| PenDataFromBuffer( &hpndt, 0, lpbBuf,
cbBufMax, &dwState ) < 0)
DestroyPenData( hpndt );
cbHpndt -= cbRead;
- Software for developers
Software for Android Developers
- More information resources
Unix Manual Pages