?
Solved

Copy richedit in TMetafile ?

Posted on 2003-03-04
9
Medium Priority
?
448 Views
Last Modified: 2013-11-22
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
0
Comment
Question by:sierra20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 34

Expert Comment

by:Slick812
ID: 8069543
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;
0
 

Author Comment

by:sierra20
ID: 8071341
Hi,
 no, its doesn't resolve the problem.

0
 

Author Comment

by:sierra20
ID: 8088407
Hi,

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

thanks
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 34

Expert Comment

by:Slick812
ID: 8089848
maybe you should ask to Delete this question
0
 

Author Comment

by:sierra20
ID: 8089939
where do i go to do that???
0
 
LVL 34

Expert Comment

by:Slick812
ID: 8089997
some info about that is here

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

and go to the Community Support
0
 

Author Comment

by:sierra20
ID: 8090539
where do i go to do that???
0
 

Author Comment

by:sierra20
ID: 8090545
thanks
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 8091617
Points refunded and placed in PAQ

Computer101
E-E Admin
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month10 days, 2 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question