# wxMetafile Class Reference
[Graphics Device Interface (GDI)]

`#include </home/work/projects/wx/2.9/wx/interface/wx/metafile.h>`

Inheritance diagram for wxMetafile:
[legend]

## Detailed Description

A wxMetafile represents the MS Windows metafile object, so metafile operations have no effect in X.

In wxWidgets, only sufficient functionality has been provided for copying a graphic to the clipboard; this may be extended in a future version.

Presently, the only way of creating a metafile is to use a wxMetafileDC.

Availability: only available for the wxMSW port.

##

Library: wxCore
Category: Graphics Device Interface (GDI)

See also:
  wxMetafileDC

## Public Member Functions

| wxMetafile (const wxString &filename=wxEmptyString)
| Constructor.
| ~wxMetafile ()
| Destructor.
bool | IsOk ()
| Returns true if the metafile is valid.
bool | Play (wxDC *dc)
| Plays the metafile into the given device context, returning true if successful.
bool | SetClipboard (int width=0, int height=0)
| Passes the metafile data to the clipboard.

List of all members.

## Constructor & Destructor Documentation

wxMetafile::wxMetafile | ( | const wxString & | filename = `wxEmptyString` | ) |

Constructor.

If a filename is given, the Windows disk metafile is read in. Check whether this was performed successfully by using the IsOk() member.

wxMetafile::~wxMetafile | ( |  | ) |

Destructor.

See Object Destruction for more info.

## Member Function Documentation

bool wxMetafile::IsOk | ( |  | ) |

Returns true if the metafile is valid.

bool wxMetafile::Play | ( | wxDC * | dc | ) |

Plays the metafile into the given device context, returning true if successful.

bool wxMetafile::SetClipboard | ( | int | width = `0`,
|  | int | height = `0` |
| ) |  |  |

Passes the metafile data to the clipboard.

The metafile can no longer be used for anything, but the wxMetafile object must still be destroyed by the application.

Below is a example of metafile, metafile device context and clipboard use from the `hello.cpp` example. Note the way the metafile dimensions are passed to the clipboard, making use of the device context's ability to keep track of the maximum extent of drawing commands.

            wxMetafileDC dc;
            if (dc.IsOk())
            {
                Draw(dc, false);
                wxMetafile *mf = dc.Close();
                if (mf)
                {
                    bool success = mf->SetClipboard((int)(dc.MaxX() + 10), (int)(dc.MaxY() + 10));
                    delete mf;
                }
            }

|  | [ top ]