Home   Index   About
Ultimate Pack


Custom Search
PenDataFromBuffer

2.0

Creates a HPENDATA object from serial data in a buffer. The buffer must have been previously written by the PenDataToBuffer function.

LONG PenDataFromBuffer( LPHPENDATA lphpndt, UINT gmemFlags, LPBYTE lpBuffer, LONG cbBuf, LPDWORD lpdwState )

Parameters

lphpndt

Pointer to an uninitialized HPENDATA handle. If PenDataFromBuffer returns successfully, lphpndt points to a new HPENDATA object containing a copy of the serial points.

gmemFlags

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.

lpBuffer

Pointer to a byte buffer containing serial data.

cbBuf

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 increments.

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 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.

Return Value

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:

Constant
Description
PDR_ERROR
Parameter or overflow error.
PDR_MEMERR
Memory error.

Comments

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.

PenDataFromBuffer 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.

Example

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

if (!hfile

|| (cb = _lread(hfile, &cbHpndt, sizeof(DWORD))) == HFILE_ERROR

|| cb != sizeof(LONG))

return NULL;

while (cbHpndt > 0)

{

if ((cbRead = _lread( hfile, lpbBuf, min(cbHpndt, cbBufMax )))

== HFILE_ERROR

|| PenDataFromBuffer( &hpndt, 0, lpbBuf,

cbBufMax, &dwState ) < 0)

{

if (hpndt)

DestroyPenData( hpndt );

return NULL;

}

cbHpndt -= cbRead;

}

return hpndt;

}

See Also

PenDataToBuffer
, GetPenDataAttributes


Last news from Greatis Software

Nostalgia .Net     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 for Delphi and C++ Builder     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     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     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     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     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 projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software 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

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun