Jump to content

GpiCopyMetaFile

From EDM2
Revision as of 18:30, 6 April 2025 by Martini (talk | contribs) (Created page with "This function creates a new metafile and copies the contents of an existing loaded metafile into it. ==Syntax== GpiCopyMetaFile(hmf) ==Parameters== ; hmf (HMF) - input : Source metafile handle. ==Return Value== ; hmfNew (HMF) - returns : New metafile handle and error indicators. :; <>0 :: New metafile handle :; GPI_ERROR :: Error. ==Remarks== The source metafile must already be loaded or generated. It is identified by a metafile handle. The new metafile is i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function creates a new metafile and copies the contents of an existing loaded metafile into it.

Syntax

GpiCopyMetaFile(hmf)

Parameters

hmf (HMF) - input
Source metafile handle.

Return Value

hmfNew (HMF) - returns
New metafile handle and error indicators.
<>0
New metafile handle
GPI_ERROR
Error.

Remarks

The source metafile must already be loaded or generated. It is identified by a metafile handle. The new metafile is identified by a handle that is returned by this function, so it may be used, for example, by GpiPlayMetaFile. The new metafile is owned by the process from which this function is issued. It cannot be accessed directly from any other process. If it still exists when the process terminates, it is automatically deleted by the system. The maximum number of metafiles allowed for a given process depends on memory construction and the application.

Errors

Possible returns from WinGetLastError:

PMERR_INV_HMF (0x207E)
An invalid metafile handle was specified.
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

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

HMF    hmf;     /*  Source metafile handle. */
HMF    hmfNew;  /*  New metafile handle and error indicators. */

hmfNew = GpiCopyMetaFile(hmf);

This example uses the GpiCopyMetaFile function to make a copy of the metafile loaded using the GpiLoadMetaFile function.

#define INCL_GPIMETAFILES /* Metafile functions */
#include <os2.h>

HAB hab; /* anchor block handle */
HMF hmf, hmf2; /* metafile handle */

/* loads metafile from disk */
hmf = GpiLoadMetaFile(hab, "sample.met");
.
.
.
hmf2 = GpiCopyMetaFile(hmf); /* copy the metafile */

Related Functions