Jump to content

GpiSetMetaFileBits: Difference between revisions

From EDM2
No edit summary
Ak120 (talk | contribs)
mNo edit summary
 
Line 5: Line 5:


==Parameters==
==Parameters==
; ''hmf'' ([[HMF]]) - input
; ''hmf'' ([[HMF]]) - input: Metafile-memory handle.
: Metafile-memory handle.
 
; ''lOffset'' ([[LONG]]) - input
; ''lOffset'' ([[LONG]]) - input
: Offset, in bytes, into the metafile data from the transfer must start.
: 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.
: 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.
; ''lLength'' ([[LONG]]) - input
: Length of the metafile data.
: It must be greater or equal to 0.
: It must be greater or equal to 0.
 
; ''pbBuffer'' ([[PBYTE]]) - input: Metafile data buffer.
; ''pbBuffer'' ([[PBYTE]]) - input
: Metafile data buffer.


==Return Value==
==Return Value==
; ''rc'' ([[BOOL]]) - returns
; ''rc'' ([[BOOL]]) - returns: Success indicator.
: Success indicator.
::TRUE: Successful completion
:; TRUE
::FALSE: Error occurred.
:: Successful completion
:; FALSE
:: Error occurred.


==Remarks==
==Remarks==
Line 33: Line 24:
==Errors==
==Errors==
Possible returns from WinGetLastError:
Possible returns from WinGetLastError:
; PMERR_INV_HMF (0x207E)
; PMERR_INV_HMF (0x207E): An invalid metafile handle was specified.
: An invalid metafile handle was specified.
; PMERR_INV_METAFILE_LENGTH (0x209E): An invalid length parameter was specified with GpiSetMetaFileBits or GpiQueryMetaFileBits.
; PMERR_INV_METAFILE_LENGTH (0x209E)
; PMERR_INV_METAFILE_OFFSET (0x209F): An invalid length parameter was specified with GpiSetMetaFileBits or GpiQueryMetaFileBits.
: 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.
; 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==
==Example Code==
<PRE>
#define INCL_GPIMETAFILES /* Or use INCL_GPI, INCL_PM, */
#include &lt;os2.h&gt;
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);
</PRE>
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.
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.
<pre>
<pre>
#define INCL_GPIMETAFILES
#define INCL_GPIMETAFILES
#include &lt;OS2.H&gt;
#include <OS2.H>


HPS hps; /* Presentation-space handle. */
HPS hps; /* Presentation-space handle. */

Latest revision as of 01:54, 24 November 2025

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

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