Solved

draw a multiline text like a memo control

Posted on 2001-06-09
3
804 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
[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
  • 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

Technology Partners: 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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

689 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