## wxMetafile

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.

Derived from

wxObject

Include files

<wx/metafile.h>

See also

wxMetafileDC

Members

wxMetafile::wxMetafile
wxMetafile::~wxMetafile
wxMetafile::Ok
wxMetafile::Play
wxMetafile::SetClipboard

### wxMetafile::wxMetafile

wxMetafile(const wxString& filename = "")

Constructor. If a filename is given, the Windows disk metafile is read in. Check whether this was performed successfully by using the wxMetafile::Ok member.

### wxMetafile::~wxMetafile

~wxMetafile()

Destructor.

### wxMetafile::Ok

bool Ok()

Returns true if the metafile is valid.

### wxMetafile::Play

bool Play(wxDC *dc)

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

### wxMetafile::SetClipboard

bool 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.Ok())
      {
        Draw(dc, false);
        wxMetafile *mf = dc.Close();
        if (mf)
        {
          bool success = mf->SetClipboard((int)(dc.MaxX() + 10), (int)(dc.MaxY() + 10));
          delete mf;
        }
      }