Use GDI to operate on the EMF file [5]: getenhmetafiledescription-get the description text of the EMF file

Source: Internet
Author: User
Descriptive descriptions can be written at the same time when the EMF file is created using the createenhmetafile function;

You can use the getenhmetafiledescription function to read the description text of the EMF file.

The explanatory text in this example is very simple, but the format of the standard explanatory text should be:ProgramName #0 file title #0 #0

Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; button2: tbutton; procedure alert (Sender: tobject); Procedure button1click (Sender: tobject); Procedure button2click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} var hmetafile: henhmetafile; {EMF file handle} {creates an EMF file with instructions} procedure tform1.formcreate (Sender: tobject); const Path = 'C: \ temp \ mymeatefile. emf'; description = 'abcde'; {description as an EMF file} var metafiledc: HDC; begin {create and write description} metafiledc: = createenhmetafile (0, pchar (PATH ), nil, pchar (description); {drawing} rectangle (metafiledc, 11, 11,111,111); {ends editing, saving the file, and returning the file handle} hmetafile: = closeenhmetafile (metafiledc ); {Delete DC} deleteobject (metafiledc); end; {read EMF file description} procedure tform1.button1click (Sender: tobject); var descriptionsize: integer; {description segment size} descriptionbuf: pchar; {memory pointer accepted description} begin {obtain size} descriptionsize: = getenhmetafiledescription (hmetafile, 0, nil); {allocate memory} getmem (descriptionbuf, descriptionsize ); {obtain description} getenhmetafiledescription (hmetafile, descriptionsize, descriptionbuf); {display description} showmessage (descriptionbuf); {ABCDE} {release memory} freemem (descriptionbuf); end; {drawn in form} procedure tform1.button2click (Sender: tobject); begin playenhmetafile (canvas. handle, hmetafile, rect (11,11, 111,111); end; {Delete EMF file handle} procedure tform1.formdestroy (Sender: tobject); begin deleteenhmetafile (hmetafile); end.
 
  
 

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.