Solved

draw a multiline text like a memo control

Posted on 2001-06-09
3
799 Views
Last Modified: 2010-04-06
I need a way to draw a multiline text on a canvas - just as in a Memo control. I think the difficulty is how to deal with 'wordwrap'. I have tried the DrawText (with DT_TEXTCONTROL) but it didn't work!

Any suggestion?
0
Comment
Question by:luckybat
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
f15iaf earned 100 total points
ID: 6171421
This is the example of program which draws mulit line text from memo1 to the canvas of the form


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
        rec:trect;
begin
        rec:=self.canvas.cliprect;
        //self.Canvas.TextOut(0,0,'vadim');
        drawtext(self.canvas.handle,pchar(memo1.text),length(memo1.text),rec,dt_wordbreak);
end;

end.
0
 

Author Comment

by:luckybat
ID: 6171450
f15iaf,thank you!

I have tried to use DrawText with DT_WORDBREAK. But the text looked not like in the memo. There are some space in the right of each line. The charset I am using is GB_2312. Can you tell me the reason?
0
 
LVL 3

Expert Comment

by:f15iaf
ID: 6171478
I don't have a problem on my computer.
I realy don't know how to explain it
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now