TEnhMetaFile

Source: source/classes/tenhmeta.prg

Inherits from: TControl

TEnhMetaFile displays Windows Enhanced Metafiles (EMF) inside FiveWin windows and dialogs. It is a full TControl subclass supporting sizing, positioning, zoom in/out, shadow effects, and resource cleanup. EMF files contain vector graphics that scale without quality loss, making them ideal for diagrams, logos, and print-preview content.

Key DATA Members

DATATypeDescription
hMetaNumeric (Handle)Enhanced metafile handle (HENHMETAFILE)
nWidthNumericLogical width of the metafile
nHeightNumericLogical height of the metafile
nXZoomNumericX-axis zoom factor (default 2)
nYZoomNumericY-axis zoom factor (default 4)
nXorigNumericX-axis scroll origin offset
nYorigNumericY-axis scroll origin offset
lZoomLogicalWhether zoom mode is currently active
lShadowLogicalShow shadow effect around the control (default .T.)

Methods

MethodDescription
New( nTop, nLeft, nW, nH, cFile, oWnd )Create a new TEnhMetaFile control that loads and displays an EMF file
Redefine( nId, cFile, oWnd )Redefine from a dialog resource template
SetFile( cFile )Load a new EMF file, replacing the current one
ZoomIn()Zoom into the metafile (divides nWidth/nHeight by nXZoom/nYZoom)
ZoomOut()Zoom out of the metafile (restores original dimensions)
SetZoomFactor( nX, nY )Change the zoom factor and adjust the current zoom state
SetOrg( nX, nY )Set the scroll origin for panning the metafile view
End()Release the metafile handle and call the superclass End()

EMF Command

TEnhMetaFile can be created directly using the EMF command syntax:

@ nRow, nCol EMF oEmf FILE cFile OF oWnd SIZE nW, nH

Example

#include "FiveWin.ch"

function Main()

   local oWnd, oEmf

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

   @ 10, 10 EMF oEmf FILE "diagram.emf" OF oWnd SIZE 560, 400

   oEmf:lShadow := .T.

   // Button to zoom in
   @ 420, 10 BUTTON "Zoom In" OF oWnd SIZE 80, 25 ;
      ACTION oEmf:ZoomIn()

   @ 420, 100 BUTTON "Zoom Out" OF oWnd SIZE 80, 25 ;
      ACTION oEmf:ZoomOut()

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

See Also