|
PenDataToBuffer
2.0
Writes the data in an existing HPENDATA object to a serial buffer.
LONG PenDataToBuffer( HPENDATA hpndt, LPBYTE lpBuffer, LONG cbBuf, LPDWORD lpdwState )
Parameters
hpndt
Handle to the HPENDATA object.
lpBuffer
Pointer to an empty buffer.
cbBuf
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
the HPENDATA object. To read all data from the object in this case, the application must
call PenDataToBuffer 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.
lpdwState
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.
Return Value
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:
Constant
| Description
| PDR_ERROR
| Parameter or other unspecified error.
| PDR_MEMERR
| Memory error.
| PDR_PNDTERR
| Invalid HPENDATA object.
| PDR_VERSIONERR
| Could not convert old HPENDATA object.
|
Comments
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 .
Example
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 )
{
BYTE lpbBuf[cbBufMax];
DWORD dwState = 0L; // Must initialize to zero
LONG cb;
LONG cbSize;
if (!hfile || !hpndt)
return FALSE;
// Get size and save to file
if (GetPenDataAttributes(hpndt, (LPVOID)&cbSize, GPA_SIZE) < 0)
return FALSE;
// 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)
return FALSE;
// 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 FALSE;
}
return (cb >= 0L); // Return TRUE if cb >= 0
}
See Also
PenDataFromBuffer
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|