Solved

draw a multiline text like a memo control

Posted on 2001-06-09
3
803 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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