Jump to content

GpiQueryMetaFileBits: Difference between revisions

From EDM2
Created page with "This function transfers a metafile to application storage. ==Syntax== GpiQueryMetaFileBits(hmf, lOffset, lLength, pbData) ==Parameters== ; hmf (HMF) - input : Memory-metafile handle. ; lOffset (LONG) - input : Byte offset. : Offset into the metafile data from which the transfer must start. This is useful in instances where the metafile data is too long to fit into a single application buffer. It must be greater or equal to 0. ; lLength (LONG) - input : L..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 5: Line 5:


==Parameters==
==Parameters==
; hmf ([[HMF]]) - input
; hmf ([[HMF]]) - input: Memory-metafile handle.
: Memory-metafile handle.
; lOffset ([[LONG]]) - input: Byte offset.
 
; lOffset ([[LONG]]) - input
: Byte offset.
: Offset into the metafile data from which the transfer must start. This is useful in instances where the metafile data is too long to fit into a single application buffer. It must be greater or equal to 0.
: Offset into the metafile data from which the transfer must start. This is useful in instances where the metafile data is too long to fit into a single application buffer. It must be greater or equal to 0.
 
; lLength (LONG) - input: Length in bytes of the metafile data to copy.
; lLength ([[LONG]]) - input
: Length in bytes of the metafile data to copy.
: It must be greater or equal to 0.
: It must be greater or equal to 0.
 
; pbData ([[PBYTE]]) - output: Metafile data.
; pbData ([[PBYTE]]) - output
: Metafile data.
: Address in application storage into which the metafile data is copied.
: Address in application storage into which the metafile data is copied.


==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 23:
==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)
; PMERR_TOO_MANY_METAFILES_IN_USE (0x2106): The maximum number of metafiles allowed for a given process was exceeded.
: 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_TOO_MANY_METAFILES_IN_USE (0x2106)
: The maximum number of metafiles allowed for a given process was exceeded.


==Example Code==
==Example Code==
<PRE>
#define INCL_GPIMETAFILES /* Or use INCL_GPI, INCL_PM, */
#include &lt;os2.h&gt;
HMF    hmf;    /* Memory-metafile handle. */
LONG    lOffset; /* Byte offset. */
LONG    lLength; /* Length in bytes of the metafile data to copy. */
PBYTE  pbData;  /* Metafile data. */
BOOL    rc;      /* Success indicator. */
rc = GpiQueryMetaFileBits(hmf, lOffset, lLength, pbData);
</PRE>
This example uses the GpiQueryMetaFileBits function to retrieve the graphics-order data from the specified metafile. The GpiQueryMetaFileLength function returns the length of the metafile.
This example uses the GpiQueryMetaFileBits function to retrieve the graphics-order data from the specified metafile. The GpiQueryMetaFileLength function returns the length of the metafile.
<pre>
<pre>
#define INCL_GPIMETAFILES /* Metafile functions */
#define INCL_GPIMETAFILES /* Metafile functions */
#define INCL_DOSMEMMGR /* DOS Memory Manager Functions */
#define INCL_DOSMEMMGR /* DOS Memory Manager Functions */
#include &lt;os2.h&gt;
#include <os2.h>


HPS hps; /* presentation space handle */
HPS hps; /* presentation space handle */

Latest revision as of 01:53, 24 November 2025

This function transfers a metafile to application storage.

Syntax

GpiQueryMetaFileBits(hmf, lOffset, lLength, pbData)

Parameters

hmf (HMF) - input
Memory-metafile handle.
lOffset (LONG) - input
Byte offset.
Offset into the metafile data from which the transfer must start. This is useful in instances where the metafile data is too long to fit into a single application buffer. It must be greater or equal to 0.
lLength (LONG) - input
Length in bytes of the metafile data to copy.
It must be greater or equal to 0.
pbData (PBYTE) - output
Metafile data.
Address in application storage into which the metafile data is copied.

Return Value

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

Remarks

The total length of a metafile can be found from the data returned by GpiQueryMetaFileLength. This function allows an application to retrieve the data in units of a manageable size.

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.
PMERR_TOO_MANY_METAFILES_IN_USE (0x2106)
The maximum number of metafiles allowed for a given process was exceeded.

Example Code

This example uses the GpiQueryMetaFileBits function to retrieve the graphics-order data from the specified metafile. The GpiQueryMetaFileLength function returns the length of the metafile.

#define INCL_GPIMETAFILES /* Metafile functions */
#define INCL_DOSMEMMGR /* DOS Memory Manager Functions */
#include <os2.h>

HPS hps; /* presentation space handle */
HMF hmf; /* metafile handle */
LONG cBytes; /* metafile length */
LONG off; /* metafile byte offset */
PBYTE pbBuffer; /* metafile data buffer */

hmf = GpiLoadMetaFile(hps, "sample.met");
cBytes = GpiQueryMetaFileLength(hmf); /* gets length of metafile */

/* Allocate the buffer for the metafile data. */
DosAllocMem((VOID *)pbBuffer, (ULONG)cBytes, PAG_COMMIT | PAG_READ | PAG_WRITE);

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

Related Functions