Link to home
Start Free TrialLog in
Avatar of sierra20
sierra20

asked on

Copy richedit in TMetafile ?

Hi,  
 I want to take the text in the richedit and put it in my metafile. Now the problem is that i loose part of my text if i insert the richedit text to much down in the page of the metafile.

 In the richedit, i put 20 line, each line with a dirrerent number :
Line 1 = 1
Line 2 = 2
...
...
Line 20 = 20

If I insert my richedit in the left-top corner of the metafile, i see my line appear in the metafile but no more line appear after 1/4 of the height of the metafile even if i put Range.rc.Bottom higher that the 1/4 of the height of the metafile. (EX : Line 1 to 10 appear) If i put the richedit text 1 inch lower than the top of the metafile, less line appear because the line disappear always after 1/4 height of the metafile. (EX :Line 1 to 7 appear)

Here the code i use to copy the richedit in the metafile. I use the same code to copy the richedit to a bitmap without any problem. Could it be the TMetafilecanvas who causing the problem ?
 
procedure TFMemoFax.Button2Click(Sender: TObject);
var MFile : TMetaFile;
    MFileCanvas : TMetaFileCanvas;
    Range : TFormatRange;
    PrintDialog : TPrintDialog;
    PrintBorder : TRect;
    HorzSizeMM, VertSizeMM : integer;

 Function mmToInch(mm : real) : real;
 begin
  Result := mm / 25.4;
 end;

Begin
 MFile := TMetaFile.Create;
 MFile.Width  := 1728;
 MFile.Height := 2232;

 MFileCanvas := TMetaFileCanvas.Create(MFile, 0);

 REMemoFax.WordWrap := false;
 REMemoFax.Font.Height := -40;//change height of font to appear the right size on the metafile

 FillChar(Range, SizeOf(TFormatRange), 0);
 Range.hdc := MFileCanvas.Handle;
 Range.hdcTarget := MFileCanvas.Handle;//Printer.Handle;
 Range.rc.left := Trunc(mmToInch(29) * 1440);
 Range.rc.top := Trunc(mmToInch(150) * 1440);
 Range.rc.right := Trunc(mmToInch(400) * 1440);  
 Range.rc.Bottom := Trunc(mmToInch(600) * 1440);
 Range.rcPage := Range.rc;
 Range.chrg.cpMax := -1;
 Range.chrg.cpMin := 0;

 SendMessage(REMemoFax.Handle, EM_FORMATRANGE, 1, LongInt(@Range));
 SendMessage(REMemoFax.Handle, EM_FORMATRANGE, 0, 0);

 REMemoFax.WordWrap := true;
 REMemoFax.Font.Size := 14;

 MFileCanvas.Free;

 MFile.SaveToFile('c:\test.EMF');
 MFile.Free;
 
 Printer.Orientation := poPortrait;
 PrintDialog := TPrintDialog.Create(Self);
 PrintDialog.Options := [poPrinttoFile, poWarning];
 if PrintDialog.Execute
  then
   begin
    PrintBorder.Left := 0;
    PrintBorder.Top := 0;
    PrintBorder.Right := (Printer.PageWidth - PrintBorder.Left);
    PrintBorder.Bottom := (Printer.PageHeight - PrintBorder.Top);

    MFile := TMetaFile.Create;
    MFile.LoadFromFile('c:\test.EMF');

    Printer.BeginDoc;
    Printer.Canvas.StretchDraw(PrintBorder, MFile);
    MFile.Free;
    Printer.EndDoc;
    Refresh;
   end;
 PrintDialog.Free;
end;



Im using Delphi 5.

Thanks in advance for any help

Sierra
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

can't have time to test this, but I know I have had problems with the .EMF extention if I do Not set the Metafile Enhanced to true


MFile := TMetaFile.Create;
MFile.Enhanced := True;
MFile.Width  := 1728;
MFile.Height := 2232;
Avatar of sierra20
sierra20

ASKER

Hi,
 no, its doesn't resolve the problem.

Hi,

I found my problem, i had to install an update of richedit v3 in windows nt 4.

thanks
maybe you should ask to Delete this question
where do i go to do that???
some info about that is here

https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp#8

and go to the Community Support
where do i go to do that???
thanks
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial