Board index » delphi » please help: problems with MetafileCanvas

please help: problems with MetafileCanvas

Hi all,

I have some graphical problems with a metafile object.
What I want to do with this code is a small preview of a larger paint area.
And I do already get this preview, but it seems I have not set the correct
borders.
because: When I place i.e. some text in the right bottom corner, it's not
visible in the preview.
              All other positions are ok.

The biggest problem (i don't understand it at all) is the SetViewportExtEx.
What is this command for ? And what does nXExtent, nYExtent mean ?

The relevant code I have done for this job:
   EMF:= TMetafile.Create;
   EMF.Enhanced:= true;
   EMF.MMWidth:= A;  // A is my paper width in pixel
   EMF.MMHeight:= B; // B is my paper height in pixel
   MetaCanvas:= TMetafileCanvas.Create(EMF,0);
   SetMapMode(MetaCanvas.Handle, MM_ISOTROPIC);
   SetWindowExtEx(MetaCanvas.Handle,A,B, nil);
   SetViewportExtEx(MetaCanvas.Handle, Round(A*0.378), Round(B*0.378), nil);

In the Previewform.Show I do this:
   PreviewPaper.Picture.Assign(EMF);

I would be very happy, if someone knows my problem an could help.

Bye,
Thomas

 

Re:please help: problems with MetafileCanvas


Hi all,

I have some graphical problems with a metafile object.
What I want to do with this code is a small preview of a larger paint area.
And I do already get this preview, but it seems I have not set the correct
borders.
because: When I place i.e. some text in the right bottom corner, it's not
visible in the preview.
              All other positions are ok.

The biggest problem (i don't understand it at all) is the SetViewportExtEx.
What is this command for ? And what does nXExtent, nYExtent mean ?

The relevant code I have done for this job:
   EMF:= TMetafile.Create;
   EMF.Enhanced:= true;
   EMF.MMWidth:= A;  // A is my paper width in pixel
   EMF.MMHeight:= B; // B is my paper height in pixel
   MetaCanvas:= TMetafileCanvas.Create(EMF,0);
   SetMapMode(MetaCanvas.Handle, MM_ISOTROPIC);
   SetWindowExtEx(MetaCanvas.Handle,A,B, nil);
   SetViewportExtEx(MetaCanvas.Handle, Round(A*0.378), Round(B*0.378), nil);

In the Previewform.Show I do this:
   PreviewPaper.Picture.Assign(EMF);

I would be very happy, if someone knows my problem an could help.

Bye,
Thomas

Re:please help: problems with MetafileCanvas


This may not directly deal with your question, but I saw something in your
code that may be a problem. You are assigning pixel dimensions to MMWidth
and MMHeight, which are supposed to be measurements in millimeters (hence
the MM).
--
Jon
http://home1.gte.net/jqjacobs/index.htm
This posting was made entirely from recycled electrons. No innocent atoms
were harmed.
Quote
"Thomas Wormser" <thwo...@aol.com> wrote in message

news:3c10b40b$1_1@dnews...
Quote
> Hi all,

> I have some graphical problems with a metafile object.
> What I want to do with this code is a small preview of a larger paint
area.
> And I do already get this preview, but it seems I have not set the correct
> borders.
> because: When I place i.e. some text in the right bottom corner, it's not
> visible in the preview.
>               All other positions are ok.

> The biggest problem (i don't understand it at all) is the
SetViewportExtEx.
> What is this command for ? And what does nXExtent, nYExtent mean ?

> The relevant code I have done for this job:
>    EMF:= TMetafile.Create;
>    EMF.Enhanced:= true;
>    EMF.MMWidth:= A;  // A is my paper width in pixel
>    EMF.MMHeight:= B; // B is my paper height in pixel
>    MetaCanvas:= TMetafileCanvas.Create(EMF,0);
>    SetMapMode(MetaCanvas.Handle, MM_ISOTROPIC);
>    SetWindowExtEx(MetaCanvas.Handle,A,B, nil);
>    SetViewportExtEx(MetaCanvas.Handle, Round(A*0.378), Round(B*0.378),
nil);

> In the Previewform.Show I do this:
>    PreviewPaper.Picture.Assign(EMF);

> I would be very happy, if someone knows my problem an could help.

> Bye,
> Thomas

Other Threads