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(Sen der: 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(MFi le, 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;//Print er.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.Hand le, EM_FORMATRANGE, 1, LongInt(@Range));
SendMessage(REMemoFax.Hand le, 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:\tes t.EMF');
Printer.BeginDoc;
Printer.Canvas.StretchDraw (PrintBord er, MFile);
MFile.Free;
Printer.EndDoc;
Refresh;
end;
PrintDialog.Free;
end;
Im using Delphi 5.
Thanks in advance for any help
Sierra
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(Sen
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(MFi
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;//Print
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.Hand
SendMessage(REMemoFax.Hand
REMemoFax.WordWrap := true;
REMemoFax.Font.Size := 14;
MFileCanvas.Free;
MFile.SaveToFile('c:\test.
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:\tes
Printer.BeginDoc;
Printer.Canvas.StretchDraw
MFile.Free;
Printer.EndDoc;
Refresh;
end;
PrintDialog.Free;
end;
Im using Delphi 5.
Thanks in advance for any help
Sierra
ASKER
Hi,
no, its doesn't resolve the problem.
no, its doesn't resolve the problem.
ASKER
Hi,
I found my problem, i had to install an update of richedit v3 in windows nt 4.
thanks
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
ASKER
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
https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp#8
and go to the Community Support
ASKER
where do i go to do that???
ASKER
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
MFile := TMetaFile.Create;
MFile.Enhanced := True;
MFile.Width := 1728;
MFile.Height := 2232;