Re:MetafileCanvas Problems
Quote
Ronald Sawyer <rsaw...@vista-soft.com> wrote in message
news:36FABB65.47E6BC5F@vista-soft.com...
Quote
>Below is some sample code:
> TMetafile *MyMetafile = new TMetafile;
> MyMetafile->LoadFromFile(ListBox1->Items->Strings[0].c_str());
> int Width, Height;
> Width = MyMetafile->MMWidth;
> Height = MyMetafile->MMHeight;
> TMetafileCanvas *MyMetafileCanvas = new TMetafileCanvas(MyMetafile,
>PaintBox1->Canvas->Handle);
> MyMetafile->MMWidth = Width;
> MyMetafile->MMHeight = Height;
If you check the source, this isn't much help. Rather be sure to set the
MMWidth and MMHeight properties BEFORE MetafileCanvas creation, and you will get
a Metafile of the correct dimensions. Otherwise these properties are set by the
DC you pass (PaintBox1->Canvas->Handle in this case). Also, don't use "Width"
and "Height", but rather "width" and "height", since the caps make it appear to
be referring to the form in which this code appears (if any). Perhaps the
scoping rules protects from this, but it could be confusing to others.
Your problem, though, may be with the Clipping Region applied to your metafile.
When you create the TMetafileCanvas, the clipping region is set according to
either: a) the MMWidth and MMHeight properties; or b) the Reference DC passed.
I don't remember which at the moment. I do know, however, that I had troubles
whenever I tried to work with a metafile larger than the reference DC. The
reason was improper use of Windows graphics; you should use clipping regions to
show the user the viewable region only. The metafile is then actually larger
than the reference DC, but you only see the part within the Clipping rectangle.
I did not run into this until I tested my app on an NT machine.
For more help, look in the Win32 help under clipping regions and possibly in
DejaNews under things like region, clipping, ClipRect, etc.
Hope that helps!! :)
Joshua D. Bush -0-0-0-0-0-0-0-0-0-0-0-0-0-0-0- The Scarlet Pumpkin