Operating EMF files with GDI [7]: graphic commands in enumenhmetafile and playenhmetafilerecord-enumeration files

Source: Internet
Author: User
Enumenhmetafile (DC: HDC; {target device handle; if the callback function does not require playback, this parameter is 0} EMF: henhmetafile; {metadata file handle} enhmetafunc: tfnenhmfenumproc; {callback function pointer; For the callback function Format, see} data: pointer; {Custom Data Pointer} const rect: trect {size to be output; if Dc = 0, this parameter will be ignored}): bool; // The callback function Format and parameters used by enumenhmetafile. playenhmetafilerecord basically uses these parameters: function enhmetafunc (displaysurface: HDC; {target device handle; if the callback function does not need to be played back, this parameter is 0} var metafiletable: thandletable; {handle table array pointer, the array contains the hgdiobj object (paint brush, paint brush, etc ); element 1 is the file handle} var metafilerecord: tenhmetarecord; {The tenhmetarecord pointer of the Metafile record. The tenhmetarecord structure is shown in the table below} objectcount: integer; {Number of object handles, that is, the number of graphic objects in the metafiletable of the handle table} var data: longint {Custom Data Pointer}): integer; stdcall; // tenhmetarecord structure: tagenhmetarecord = packed record itype: DWORD; {type} nsize: DWORD; {size} dparm: array [0 .. 0] of DWORD; {parameter array} end; // tenhmetarecord. possible values of itype: emr_header = 1; emr_polybezr = 2; emr_polygon = 3; emr_polyline = 4; emr_polybezierto = 5; emr_polylineto = 6; emr_polypolyline = 7; emr_polypolygon = 8; duration = 9; emr_set1_worgex = 10; emr_setviewportextex = 11; duration = 12; duration = 13; emr_eof = 14; emr_setpixelv = 15; emr_setmapperflags = $10; emr_setmapmode = 17; emr_setbkmode = 18; priority = 19; emr_setrop2 = 20; priority = 21; emr_settextalign = 22; priority = 23; emr_settextcolor = 24; emr_setbkcolor = 25; priority = 26; emr_movetoex = 27; emr_setmetargn = 28; cost = 29; cost = 30; cost = 31; cost = 32; emr_savedc = 33; emr_restoredc = 34; emr_setworldtransform = 35; emr_modifyworldtransform = 36; emr_selectobject = 37; emr_createpen = 38; records = 39; emr_deleteobject = 40; emr_anglearc = 41; emr_ellipse = 42; emr_rectangle = 43; records = 44; emr_arc = 45; emr_chord = 46; emr_pie = 47; emr_selectpalette = 48; emr_createpalette = 49; partition = 50; partition = 51; partition = 52; partition = 53; emr_lineto = 54; emr_arcto = 55; emr_polydraw = 56; emr_setarcdirection = 57; lifecycle = 58; emr_beginpath = 59; emr_endpath = 60; emr_closefigure = 61; emr_fillpath = 62; lifecycle = 63; emr_strokepath = $40; emr_flattenpath = 65; emr_widenpath = 66; token = 67; emr_abortpath = 68; emr_gdicomment = 70; emr_fillrgn = 71; emr_framergn = 72; emr_invertrgn = 73; emr_paintrgn = 74; token = 75; emr_bitblt = 76; token = 77; emr_maskblt = 78; emr_plgblt = 79; emr_setdibitstodevice = 80; priority = 81; priority = 82; priority = 83; priority = 84; emr_polybezier16 = 85; emr_polygon16 = 86; emr_polyline16 = 87; priority = 88; emr_polylineto16 = 89; emr_polyline16 = 90; emr_polypolygon16 = 91; emr_polydraw16 = 92; emr_createmonobrush = 93; priority = 94; emr_extcreatepen = 95; priority = 96; Limit = 97; encoding = 98; emr_createcolorspace = 99; emr_setcolorspace = 100; encoding = 101; emr_glsrecord = 102; encoding = 103; emr_pixelformat = 104; emr_drawescape = 105; emr_extescape = 106; emr_startdoc = 107; token = 108; token = 109; emr_namedescape = 110; token = 111; token = 112; token = 113; emr_alphablend = 114; emr_alphadibblend = 115; emr_transparentblt = 116; emr_transparentdib = 117; emr_gradientfill = 118; emr_setlinkedufcm = 119; emr_settextjustification = 120;
 
   
 

In the following example, a primitive file is created in the memory, and a straight line, a rectangle, and two ovans are drawn;

The control displays part and all of the metadata files.

Run:


Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, extctrls; Type tform1 = Class (tform) radiogroup1: tradiogroup; procedure formcreate (Sender: tobject); Procedure formdestroy (Sender: tobject); Procedure radiogroup1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} var hmetafile: henhmetafile; {EMF file handle} radiogroupitemindex: integer =-1; // callback function of enumenhmetafile: displaysurface: HDC; var metafiletable: thandletable; var metafilerecord: tenhmetarecord; objectcount: integer; var data: longint): integer; stdcall; var itype: integer; begin case radiogroupitemindex of 1: itype: = emr_rectangle; 2: itype: = emr_ellipse; end; If metafilerecord. itype = itype then begin convert (displaysurface, metafiletable, metafilerecord, objectcount); Result: = 1; end; Procedure tform1.formcreate (Sender: tobject); var metafiledc: HDC; begin {file established in memory} metafiledc: = createenhmetafile (0, nil); movetoex (metafiledc, 0, 0, nil); lineto (metafiledc, 100,100 ); {rectangle} rectangle (metafiledc, 10, 10, 30, 30); {elliptic} ellipse (metafiledc, 30, 30, 50, 50); ellipse (metafiledc, 45, 45, 65, 65); hmetafile: = closeenhmetafile (metafiledc); deleteobject (metafiledc); radiogroup1.items. commatext: = 'entire Metafile, where the rectangle, the elliptic '; end; Procedure tform1.radiogroup1click (Sender: tobject); begin repaint; radiogroupitemindex: = radiogroup1.itemindex; if radiogroupitemindex = 0 then playenhmetafile (canvas. handle, hmetafile, clientrect) else enumenhmetafile (canvas. handle, hmetafile, @ myenhmetafunc, nil, clientrect); end; Procedure tform1.formdestroy (Sender: tobject); begin deleteenhmetafile (hmetafile); end.
 
   
 

Form file:

 
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 197 clientwidth = 325 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false position = podesktopcenter oncreate = formcreate ondestroy = formdestroy pixelsperinch = 96 textheight = 13 object radiogroup1: tradiogroup left = 216 Top = 8 width = 101 Height = 113 caption = 'radiogroup1' taborder = 0 onclick = radiogroup1click endend

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.