Writes the data in an existing HPENDATA
object to a serial buffer.
LONG PenDataToBuffer( HPENDATA hpndt, LPBYTE lpBuffer, LONG cbBuf, LPDWORD lpdwState )
Handle to the HPENDATA
Pointer to an empty buffer.
Size of the buffer in bytes. The buffer must be at least 64 bytes in size. If
the buffer serves as an intermediate holding area, it need not be as large as
object. To read all data from the object in this case, the application must
successively, each time copying the data from the buffer that lpBuffer
points to before the next call. The example below illustrates this technique
by writing an HPENDATA
object in cbBuf
increments to a file.
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 PenDataToBuffer
. Between successive calls to PenDataToBuffer
, the application must not alter the value that lpdwState
points to. lpdwState
can be NULL to signify that the buffer is large enough to contain the entire HPENDATA
object. This implies that subsequent calls to PenDataToBuffer
are not necessary.
If successful, PenDataToBuffer
returns the number of bytes transferred into 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
until the final transfer, when it is typically some smaller value. 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 other unspecified error.
||Invalid HPENDATA object.
||Could not convert old HPENDATA object.
The buffer need not be large enough to accommodate the entire HPENDATA
object. To allocate a buffer large enough for a single transfer, the
application can determine the required size with the GetPenDataAttributes
subfunction GPA_SIZE .
The following example shows how to save an HPENDATA
object to a file (hfile) that has already been opened for writing. The length of the pen data is
saved in the file before writing the pen data itself:
#define cbBufMax 1024
BOOL NEAR PASCAL WritePenData( HFILE hfile, HPENDATA hpndt )
DWORD dwState = 0L; // Must initialize to zero
if (!hfile || !hpndt)
// Get size and save to file
if (GetPenDataAttributes(hpndt, (LPVOID)&cbSize, GPA_SIZE) < 0)
// write size of pen data to file so that it can be used while reading it back
if (_lwrite(hfile, &cbSize, sizeof(LONG)) == HFILE_ERROR)
// Write the pen data in chunks, and repeat until done
while ((cb = PenDataToBuffer(hpndt, lpbBuf,
cbBufMax, &dwState )) > 0L)
if (_lwrite( hfile, lpbBuf, (UINT)cb ) == HFILE_ERROR)
return (cb >= 0L); // Return TRUE if cb >= 0
- Software for developers
Software for Android Developers
- More information resources
Unix Manual Pages