Solved

draw a multiline text like a memo control

Posted on 2001-06-09
3
802 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 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