Recent Posts
Selamat datang di Coding Delphi Land Weblog kumpulan source code pemogram delphi
(Bukan maksud untuk menggurui tetapi marilah kita berbagi ilmu tuk perkembangan kemajuan teknologi kita
Minggu, 15 November 2009
Copy Text From Richedit To Image
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, jpeg, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
RichEdit1: TRichEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
for i := 1 to length(RichEdit1.Text) - 1 do
begin
if RichEdit1.Text[i] = #13 then
with Image1.Canvas do
MoveTo(0, PenPos.Y + TextHeight(RichEdit1.Lines.Strings[0]));
RichEdit1.SelStart := i;
RichEdit1.SelLength := 1;
with image1.Canvas do
begin
Font.Color := RichEdit1.SelAttributes.Color;
Font.Size := RichEdit1.SelAttributes.Size;
Font.Style := RichEdit1.SelAttributes.Style;
if (RichEdit1.Text[i] <> #13) and (char(RichEdit1.Text[i]) <> #10) then
TextOut(PenPos.X, PenPos.Y, RichEdit1.Text[i]);
end;
end;
end;
end.
0 komentar:
Posting Komentar