Create WMF

Create WMF

Post by Sprin » Tue, 25 Feb 2003 00:45:40



anyone have code that I could create WMF files. IE say

CreateWMF (Size)
CreatePolygone (Pts(), Border, Fille etc)
CreateLine(Pts(), width, Color)
CreateText(Font, Text)
CloseWMF

anything like this

Thanks- Bruce

 
 
 

Create WMF

Post by Sprin » Tue, 25 Feb 2003 00:52:35


OK Maybe I dont need this. There are many good posts here that indicate the
basics for this

Thanks


Quote:> anyone have code that I could create WMF files. IE say

> CreateWMF (Size)
> CreatePolygone (Pts(), Border, Fille etc)
> CreateLine(Pts(), width, Color)
> CreateText(Font, Text)
> CloseWMF

> anything like this

> Thanks- Bruce


 
 
 

Create WMF

Post by Mike D Sutto » Tue, 25 Feb 2003 07:07:24


Quote:> anyone have code that I could create WMF files. IE say

> CreateWMF (Size)
> CreatePolygone (Pts(), Border, Fille etc)
> CreateLine(Pts(), width, Color)
> CreateText(Font, Text)
> CloseWMF

What you're after is the CreateMetaFile() API call.  Do you really need WMF
though - It's a whole can of worms unfortunately and doesn't support all the
drawing commands you may use on a DC.  Unless you have to be using WMF's for
legacy support then I'd highly recommend you go for EMF's instead which are
far easier to work with and will support a wider range of graphics calls.
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/


 
 
 

Create WMF

Post by Sprin » Tue, 25 Feb 2003 09:16:41


Hi Mike,

Yes WMF - There are problems with EMF (this is reporoduceable and I can send
you a few to see what I am talking about) that cause problems in windows
95/98/me These examples are when you have say 2 or more  EMF files embeded
in a third Parent EMF. The resultant EMF Parent EMF will only show the First
embedded EMF in VB and many Microsoft applications (Including VB) - these
same EMF's however do show fine in Word and other Core Office applications
Fine (showing that Microsoft has different Metafile record retrieval and
playback methods for these different applications).

Let me know if you want an example.  Since what I am going to do with this
code is create a metafile of a Flexgrid (the BMP of Flexgrid.picture is to
low quality to use for what I need so a metafile is better and the WMF
supports all of the metafile record types I need)

Bruce

Of course if you do have some samples (with all object create deletes) Id
appreciate it
createfile
WriteRect (Pts, BorderColor, borderwidth, FillColor)
writetext (Font, String, x,y)
write line (color, width, x1, y1, x2, y2)
write polygon (Color, BorderWidth, pts)
closefile

etc then I will be glad to share back the finished Flexgrid metafile
routines that will account for all cells, backcolor,text, fixed and standard
cells and merged cells)



> > anyone have code that I could create WMF files. IE say

> > CreateWMF (Size)
> > CreatePolygone (Pts(), Border, Fille etc)
> > CreateLine(Pts(), width, Color)
> > CreateText(Font, Text)
> > CloseWMF

> What you're after is the CreateMetaFile() API call.  Do you really need
WMF
> though - It's a whole can of worms unfortunately and doesn't support all
the
> drawing commands you may use on a DC.  Unless you have to be using WMF's
for
> legacy support then I'd highly recommend you go for EMF's instead which
are
> far easier to work with and will support a wider range of graphics calls.
> Hope this helps,

>     Mike

>  -- EDais --

>  - Microsoft Visual Basic MVP -
> WWW: Http://EDais.earlsoft.co.uk/



 
 
 

Create WMF

Post by Mike D Sutto » Tue, 25 Feb 2003 17:00:35


Quote:> Yes WMF - There are problems with EMF (this is reporoduceable and I can
send
> you a few to see what I am talking about) that cause problems in windows
> 95/98/me These examples are when you have say 2 or more  EMF files embeded
> in a third Parent EMF. The resultant EMF Parent EMF will only show the
First
> embedded EMF in VB and many Microsoft applications (Including VB) - these
> same EMF's however do show fine in Word and other Core Office applications
> Fine (showing that Microsoft has different Metafile record retrieval and
> playback methods for these different applications).

What you may try doing is to play your child EMF's into the parent EMF's
MetaDC, then saving it all as a flat EMF file rather than using the
embedding.  You may be able to circumvent the scale mode problems by making
sure your child EMF's play well with others - By that I mean that they
include good bounds information and always restore the target DC to it's
original state as the final record (Before EOF of course..)
To do this, have a look at the SetWindowExt() and SetViewportExt()
functions, then call SaveDC() as your first call and RestoreDC() as your
last - This way anything your EMF does during it's lifetime will not affect
the parent DC after it's finished.
If this does solve your problem then I strongly suggest you use EMF's
instead, otherwise you'll have to deal with the joys of adding a placeable
metafile header to the WMF which isn't supported by the API, otherwise most
WMF import routines won't read it..

Quote:> Let me know if you want an example.  Since what I am going to do with this
> code is create a metafile of a Flexgrid (the BMP of Flexgrid.picture is to
> low quality to use for what I need so a metafile is better and the WMF
> supports all of the metafile record types I need)

Sure, I wouldn't mind an example to see if the above clears it up - It
should in theory.  You're welcome to e-mail me directly or put it on some
public webspace, only attach it here if the files are small as Binary
attachments are not often well recieved on this kind of medium.

Quote:> Of course if you do have some samples (with all object create deletes) Id
> appreciate it
> createfile

CreateMetaFile()
SaveDC()
SetMapMode(MM_ANISOTROPIC)
SetWindowExt()
SetViewportExt()

Quote:> WriteRect (Pts, BorderColor, borderwidth, FillColor)

Rectangle()

Quote:> writetext (Font, String, x,y)

TextOut() / DrawText() / ExtTextOut() / etc...

Quote:> write line (color, width, x1, y1, x2, y2)

MoveToEx()
LineTo()

Quote:> write polygon (Color, BorderWidth, pts)

PolyGon()

Quote:> closefile

RestoreDC()
CloseMetaFile()
DeleteMetaFile() // This clears the metafile handle from memory,
                 // it doesn't do anything with the file itself
                 // despite the rather scary sounding name

Quote:> etc then I will be glad to share back the finished Flexgrid metafile
> routines that will account for all cells, backcolor,text, fixed and
standard
> cells and merged cells)

The above should give you enough to get started, I don't currently have
anything online to demonstrate creating a WMF in memory but here's a
reasonably recent post on working with an EMF in memory, they're dealt with
in the same way:
http://groups.google.com/groups?selm=uzKAleMyCHA.2536%40TK2MSFTNGP09
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/


 
 
 

Create WMF

Post by Sprin » Tue, 25 Feb 2003 23:31:37


Hi Mike,

I will forward the code when I complete it ( and some samples of the Bad and
Good EMF's) - I know there are no Bad EMF's - Just Misunderstood EMF's :)

I am going to temporarily do the cheap and dirty method and use Bennet-Tecs
Metadraw to create the metafiles. The final version I will remove it and
create the metafiles directly. I keep in touch as to my progress.

As always thanks again,

Bruce



> > Yes WMF - There are problems with EMF (this is reporoduceable and I can
> send
> > you a few to see what I am talking about) that cause problems in windows
> > 95/98/me These examples are when you have say 2 or more  EMF files
embeded
> > in a third Parent EMF. The resultant EMF Parent EMF will only show the
> First
> > embedded EMF in VB and many Microsoft applications (Including VB) -
these
> > same EMF's however do show fine in Word and other Core Office
applications
> > Fine (showing that Microsoft has different Metafile record retrieval and
> > playback methods for these different applications).

> What you may try doing is to play your child EMF's into the parent EMF's
> MetaDC, then saving it all as a flat EMF file rather than using the
> embedding.  You may be able to circumvent the scale mode problems by
making
> sure your child EMF's play well with others - By that I mean that they
> include good bounds information and always restore the target DC to it's
> original state as the final record (Before EOF of course..)
> To do this, have a look at the SetWindowExt() and SetViewportExt()
> functions, then call SaveDC() as your first call and RestoreDC() as your
> last - This way anything your EMF does during it's lifetime will not
affect
> the parent DC after it's finished.
> If this does solve your problem then I strongly suggest you use EMF's
> instead, otherwise you'll have to deal with the joys of adding a placeable
> metafile header to the WMF which isn't supported by the API, otherwise
most
> WMF import routines won't read it..

> > Let me know if you want an example.  Since what I am going to do with
this
> > code is create a metafile of a Flexgrid (the BMP of Flexgrid.picture is
to
> > low quality to use for what I need so a metafile is better and the WMF
> > supports all of the metafile record types I need)

> Sure, I wouldn't mind an example to see if the above clears it up - It
> should in theory.  You're welcome to e-mail me directly or put it on some
> public webspace, only attach it here if the files are small as Binary
> attachments are not often well recieved on this kind of medium.

> > Of course if you do have some samples (with all object create deletes)
Id
> > appreciate it
> > createfile

> CreateMetaFile()
> SaveDC()
> SetMapMode(MM_ANISOTROPIC)
> SetWindowExt()
> SetViewportExt()

> > WriteRect (Pts, BorderColor, borderwidth, FillColor)

> Rectangle()

> > writetext (Font, String, x,y)

> TextOut() / DrawText() / ExtTextOut() / etc...

> > write line (color, width, x1, y1, x2, y2)

> MoveToEx()
> LineTo()

> > write polygon (Color, BorderWidth, pts)

> PolyGon()

> > closefile

> RestoreDC()
> CloseMetaFile()
> DeleteMetaFile() // This clears the metafile handle from memory,
>                  // it doesn't do anything with the file itself
>                  // despite the rather scary sounding name

> > etc then I will be glad to share back the finished Flexgrid metafile
> > routines that will account for all cells, backcolor,text, fixed and
> standard
> > cells and merged cells)

> The above should give you enough to get started, I don't currently have
> anything online to demonstrate creating a WMF in memory but here's a
> reasonably recent post on working with an EMF in memory, they're dealt
with
> in the same way:
> http://groups.google.com/groups?selm=uzKAleMyCHA.2536%40TK2MSFTNGP09
> Hope this helps,

>     Mike

>  -- EDais --

>  - Microsoft Visual Basic MVP -
> WWW: Http://EDais.earlsoft.co.uk/



 
 
 

1. Creating wmf with transparent background

I'm trying to create a scalable wmf image, and the only
tool I have that seems to be able to do this is Powerpoint
(Paint Shop converts to wmf but retains the non-scalability
of bitmap files it seems).  Does anyone know how to make
the background transparent in Powerpoint with an wmf
image?

Thanks

Bruce Anderson

2. OT: File format extensions

3. Creating WMF File from Application Printout

4. Q: I'd like to program this conversion myself- WAS: how to convert graphics

5. Creating WMF from a library

6. !!!!!!!! HELP !!!!!!!!

7. Creating wmf files

8. GL Extensions and #define paramater values

9. How to create a WMF?

10. Again: Problem with EMF scale in Win 2000, now with code to create EMF/WMF

11. Creating a Windows Metafile (WMF) then placing on clipboard

12. Creating RTF-File with WMF Graphics included

13. how to create emf/wmf file?