Enhanced Metafile Problem 
Author Message
 Enhanced Metafile Problem

currently I can create enhanced metafiles quite happily. The problem is
that when I import these images into WORD
they are huge.

Is there are way of scaling the metafile using, SetWindowExtEx  and
SetViewportExtEx ?

Does anyone have an example of using these functions with metafiles?

the "code" below is the one I believe should work!

    Public Type POINTAPI
        x                               As Long
        y                               As Long
    End Type

    Public Declare Function SetViewportExtEx Lib "gdi32" (ByVal hdc As
Long, ByVal nX As Long, ByVal nY As Long, lpSize As POINTAPI) As Long
    Public Declare Function SetWindowExtEx Lib "gdi32" (ByVal hdc As
Long, ByVal nX As Long, ByVal nY As Long, lpSize As POINTAPI) As Long

    HoutportDC = Crea{*filter*}hMetaFile(0, vbNullString, winbox,
metafile_title)

    SetWindowExtEx HoutportDC, outwidth , outheight, returndata

    SetViewportExtEx HoutportDC, paper_width, paper_height, returndata

where
        returndata is pointapi struture
        winbox is RECT structure containing the required dimensions of
the metafile
        metafile_title is a string for the metafile

        outwidth, and outheight are long integers to define the user graphical
bounds of the metafile
        paper_width, paper_height is the actual dimensions required

Crea{*filter*}hMetaFile correctly returns a handle but the other two seemed to
have no effect.

Any suggestions would be welcome

--
Best regards

Andy Stewartson

+------------------------------+---------------------------------------+
 Andy Stewartson,              | Tel: +44 1634 844400 ext. 4562
 Senior Mechanical Engineer    | Fax: +44 1634 816360
 Mechanical Design Engineering |
 Mission Systems Division      |

 Rochester, ME1 2XX            |



Tue, 27 May 2003 20:43:43 GMT  
 Enhanced Metafile Problem
Unless you have specific reason not to do so, such as you need to work
with a 10,000 x 10,000 grid at a specific scale, I always prefer to let
the OS calculate the Bounding Box for me. Here's a SNIP of Code.

'**WARNING
' Changed from "lprect as rect" to "Byval lpRect as long"
' THis allows us to pass a NULL to the OS.
' Now the GDI will calculate the Bounding Box for us! :-)
Private Declare Function apiCrea{*filter*}hMetaFile Lib "gdi32" Alias
"Crea{*filter*}hMetaFileA" _
(ByVal hDCRef As Any, ByVal lpFileName As Any, ByVal lpRect As Long,
ByVal lpDescription As String) As Long

 'Create a disk file use this line
    hdcMeta = apiCrea{*filter*}hMetaFile(hDC1, strEMFpath, 0&, vbNullString)

HTH
Stephen Lebans
http://www.*-*-*.com/
Access Code, Tips and Tricks


Quote:

> currently I can create enhanced metafiles quite happily. The problem
is
> that when I import these images into WORD
> they are huge.

> Is there are way of scaling the metafile using, SetWindowExtEx  and
> SetViewportExtEx ?

> Does anyone have an example of using these functions with metafiles?

> the "code" below is the one I believe should work!

>     Public Type POINTAPI
>         x                               As Long
>         y                               As Long
>     End Type

>     Public Declare Function SetViewportExtEx Lib "gdi32" (ByVal hdc As
> Long, ByVal nX As Long, ByVal nY As Long, lpSize As POINTAPI) As Long
>     Public Declare Function SetWindowExtEx Lib "gdi32" (ByVal hdc As
> Long, ByVal nX As Long, ByVal nY As Long, lpSize As POINTAPI) As Long

>     HoutportDC = Crea{*filter*}hMetaFile(0, vbNullString, winbox,
> metafile_title)

>     SetWindowExtEx HoutportDC, outwidth , outheight, returndata

>     SetViewportExtEx HoutportDC, paper_width, paper_height, returndata

> where
> returndata is pointapi struture
>         winbox is RECT structure containing the required dimensions of
> the metafile
> metafile_title is a string for the metafile

> outwidth, and outheight are long integers to define the user graphical
> bounds of the metafile
>         paper_width, paper_height is the actual dimensions required

> Crea{*filter*}hMetaFile correctly returns a handle but the other two seemed
to
> have no effect.

> Any suggestions would be welcome

> --
> Best regards

> Andy Stewartson

+------------------------------+---------------------------------------+
Quote:
>  Andy Stewartson,              | Tel: +44 1634 844400 ext. 4562
>  Senior Mechanical Engineer    | Fax: +44 1634 816360
>  Mechanical Design Engineering |
>  Mission Systems Division      |
>  BAE SYSTEMS Avionics Ltd      | E-mail:


- Show quoted text -

Quote:
>  Rochester, ME1 2XX            |



Tue, 27 May 2003 23:33:37 GMT  
 Enhanced Metafile Problem
Thanks Stephen,

Unfortunately this does not work for the metafiles I create! I just get
a white box!

my metafiles all have a size of either 3000x2100 or 2100x3000. but the
rect is 70000x52500
or 52500x70000 to get the image on.

Note the size of the image when read in to say Painshop Pro is 3000x2100
or 2100x3000.

I am currently using VB6SP4 on NT4.

Best regards

Andy Stewartson

+------------------------------+---------------------------------------+
 Andy Stewartson,              | Tel: +44 1634 844400 ext. 4562
 Senior Mechanical Engineer    | Fax: +44 1634 816360
 Mechanical Design Engineering |
 Mission Systems Division      |

 Rochester, ME1 2XX            |



Fri, 30 May 2003 18:58:18 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Graph 97, Metafiles and Enhanced Metafiles

2. enhanced metafile and printing problem

3. enhanced metafile

4. Need help changing palette in an enhanced metafile

5. help creating enhanced metafiles with api call

6. Rotate Enhanced Metafiles

7. Printing an Enhanced Metafile of a Contro

8. How to create an Enhanced MetaFile?!!

9. Enhanced Metafile Help Please

10. Copy a jpeg into an Enhanced Metafile

11. Font Structure in Enhanced Metafiles

12. Convert enhanced metafile(.emf) to Bitmap(.bmp)???

 

 
Powered by phpBB® Forum Software