TMetaFile

Source: source/classes/tmetafil.prg

Inherits from: TControl

TMetaFile displays both Windows Metafiles (WMF) and Enhanced Metafiles (EMF) inside FiveWin windows and dialogs. It automatically detects WMF files and converts them to EMF format for display. TMetaFile offers the same zoom, pan, and shadow features as TEnhMetaFile, with additional support for mouse wheel scrolling and coordinate system management.

Key DATA Members

DATATypeDescription
hMetaNumeric (Handle)Metafile handle (HENHMETAFILE or HMETAFILE)
nWidthNumericLogical width
nHeightNumericLogical height
nXZoomNumericX-axis zoom factor (default 1)
nYZoomNumericY-axis zoom factor (default 2)
lZoomLogicalWhether zoom mode is active
lShadowLogicalShow drop shadow (default .T.)
bMouseWheelCode blockMouse wheel event handler
nVRatioNumericVertical aspect ratio for viewport mapping

Methods

MethodDescription
New( nTop, nLeft, nW, nH, cFile, oWnd )Create a new TMetaFile control
Redefine( nId, cFile, oWnd )Redefine from dialog resource
SetFile( cFile )Load a new WMF or EMF file
ZoomIn()Zoom in (divides dimensions by nXZoom/nYZoom)
ZoomOut()Zoom out (restores original dimensions)
SetZoomFactor( nX, nY )Change the zoom multipliers
SetOrg( nX, nY )Set the scroll origin offset
MouseWheel( nKey, nDelta, nXPos, nYPos )Handle mouse wheel events (delegates to bMouseWheel)
End()Release metafile handle and call superclass End()

METAFILE Command

TMetaFile can be created directly using the METAFILE command syntax:

@ nRow, nCol METAFILE oMf FILE cFile OF oWnd SIZE nW, nH

Example

#include "FiveWin.ch"

function Main()

   local oWnd, oMeta

   DEFINE WINDOW oWnd TITLE "WMF Viewer" SIZE 600, 500

   // Display a WMF file (auto-converted to EMF internally)
   @ 10, 10 METAFILE oMeta FILE "drawing.wmf" OF oWnd SIZE 560, 400

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also