Hi Ian,

Thank you very much for your help with this problem. I did what you
suggested and found out that I am getting a 'legacy' metafile. I've been
able to convert it enhanced metafile, but Metafile object doesn't want to
accept it anyway, so I ended up with saving the metafile on the disk using
CopyMetaFile API and then reading it into a Metafile object.

Thanks again, Alex



On Wed, 8 May 2002 09:37:47 +0100, Ian Griffiths <[EMAIL PROTECTED]>
wrote:

>Do you have any means of verifying that what you're getting back is
>definitely a valid metafile handle?  Can you write an unmanaged test
>harness?
>
>Alternatively could you try calling DeleteEnhMetaFile (using P/Invoke, i.e.
>[DllImport]) and see if it returns an error.  That would at least let you
>test whether the handle you've been given is really a metafile.
>
>Actually that's a point, do you know if it's a metafile or an enhanced
>metafile?  I'm not sure that the Metafile classes can do legacy metafiles,
>only EMFs.  (It can do so-called dual enhanced metafiles, which contain
>extra stuff that avoids losing too much information when you convert to a
>legacy metafile.  But I think this is just a feature of the EMFs that it
>happens to support.  It doesn't appear to provide any API for converting
>between legacy and enhanced metafiles.)
>
>If it's a legacy metafile, I think you may need to use P/Invoke to call
>Win32 APIs to convert it.  The Win32 SDK docs explain how to do this - you
>call GetMetaFileBitsEx on the old metafile to copy its contents into a
>buffer, and then use SetWinMetaFileBits to build a new enhanced metafile
>from the old metafile.  That returns a handle to an enhanced metafile which
>you could then pass to the Metafile constructor.
>
>
>--
>Ian Griffiths
>DevelopMentor
>
>----- Original Message -----
>From: "Alex Yakhnin" <[EMAIL PROTECTED]>
>
>
>> Yes Ian,
>>
>> I'd tried Metafile with different ctors and passing IPicture.Handle - the
>> result I was getting the same "A generic error occurred in GDI+."
>exception.
>>
>>
>> Ian Griffiths <[EMAIL PROTECTED]> wrote:
>>
>> >At the risk of suggesting the obvious, have you tried the Metafile
class?
>> >It has a constructor which takes an IntPtr which is a handle to a
>metafile.
>> >You get to pass a bool specifying whether the .NET Metafile object
should
>> >delete the underlying metafile handle when it is destroyed.
>> >
>> >
>> >----- Original Message -----
>> >From: "Alex Yakhnin" <[EMAIL PROTECTED]>
>> >
>> >I've checked it - it's a metafile.
>> >What should I do with it?
>> >
>> >On Fri, 3 May 2002 18:00:35 +0200, Mattias =?iso-8859-1?Q?Sj=F6gren?=
>> ><[EMAIL PROTECTED]> wrote:
>> >
>> >>>I get exception: "A generic error occurred in GDI+".
>> >>>I am pretty much sure that I get a valid IPicture.
>> >>
>> >>Perhaps it's not a bitmap, but some other kind of picture (e.g. an
>icon).
>> >>See what IPicture.Type returns. If it's an icon, use Icon.FromHandle()
>> >instead.
>
>You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to