Jump to content

GpiSetMetaFileBits

From EDM2

This call transfers metafile data from application storage into a memory metafile.

Syntax

GpiSetMetaFileBits(hmf, lOffset, lLength, pbBuffer)

Parameters

hmf (HMF) - input
Metafile-memory handle.
lOffset (LONG) - input
Offset, in bytes, into the metafile data from the transfer must start.
This is used when the metafile data is too long to fit into a single application buffer. This parameter must be greater or equal to 0.
lLength (LONG) - input
Length of the metafile data.
It must be greater or equal to 0.
pbBuffer (PBYTE) - input
Metafile data buffer.

Return Value

rc (BOOL) - returns
Success indicator.
TRUE
Successful completion
FALSE
Error occurred.

Remarks

The application must ensure that the data is in the correct format. It should not have been changed since it was created by GpiQueryMetaFileBits. The length of the metafile is increased, if necessary, to accommodate the supplied data. If the supplied data is shorter, the metafile length is not reduced. However, in this case the metafile is still valid, if the data in it is complete and otherwise correct.

Errors

Possible returns from WinGetLastError:

PMERR_INV_HMF (0x207E)
An invalid metafile handle was specified.
PMERR_INV_METAFILE_LENGTH (0x209E)
An invalid length parameter was specified with GpiSetMetaFileBits or GpiQueryMetaFileBits.
PMERR_INV_METAFILE_OFFSET (0x209F)
An invalid length parameter was specified with GpiSetMetaFileBits or GpiQueryMetaFileBits.
PMERR_METAFILE_IN_USE (0x20D9)
An attempt has been made to access a metafile that is in use by another thread.

Example Code

#define INCL_GPIMETAFILES /* Or use INCL_GPI, INCL_PM, */
#include <os2.h>

HMF     hmf;      /* Metafile-memory handle. */
LONG    lOffset;  /* Offset, in bytes, into the metafile data from the transfer must start. */
LONG    lLength;  /* Length of the metafile data. */
PBYTE   pbBuffer; /* Metafile data buffer. */
BOOL    rc;       /* Success indicator. */

rc = GpiSetMetaFileBits(hmf, lOffset, lLength, pbBuffer);

This example shows how to copy a metafile into application storage to edit the contents and then write back to the metafile using the GpiSetMetaFileBits call.

#define INCL_GPIMETAFILES
#include <OS2.H>

HPS hps; /* Presentation-space handle. */
HMF hmf;
PBYTE pbBuffer;
LONG cBytes;
LONG lOffset;

hmf = GpiLoadMetaFile(hps, "sample.met");

/* Allocate the buffer for the metafile data. */
cBytes = GpiQueryMetaFileLength(hmf);/* gets length of metafile */
DosAllocMem((PPVOID)pbBuffer, cBytes, PAG_READ | PAG_WRITE | PAG_COMMIT);

GpiQueryMetaFileBits(hmf, /* handle of metafile */
                      lOffset, /* offset of next byte to retrieve */
                      cBytes, /* retrieves cBytes */
                      pbBuffer); /* buffer to receive metafile data */

/* . */
/* work with the metafile */
/* . */

/* write data back to the metafile */
GpiSetMetaFileBits(hmf, lOffset, cBytes, pbBuffer);

Related Functions