如何把Richedit中的内容保存为bmp?(100分)

  • 主题发起人 主题发起人 limin_chen
  • 开始时间 开始时间
L

limin_chen

Unregistered / Unconfirmed
GUEST, unregistred user!
不要用一页一页copy的方法,我正在这么做,好stupid.
 
下面示例可以将RichEdit的内容输出到一个Image中,只要你将
Image设为足够大,即可得到RichEdit中的所有内容,然后再
Image1.Picture.SaveToFile输出到一个BMP文件即可:
uses RichEdit;
procedure TForm1.Button1Click(Sender: TObject);
var
Range: TFormatRange;
LastChar, MaxLen, LogX, LogY: Integer;
begin
FillChar(Range, SizeOf(TFormatRange), 0);
with Image1, Rangedo
begin
LogX := GetDeviceCaps(Canvas.Handle, LOGPIXELSX);
LogY := GetDeviceCaps(Canvas.Handle, LOGPIXELSY);
hdc := Canvas.Handle;
hdcTarget := hdc;
rc.right := Image1.ClientWidth * 1440 div LogX;
rc.bottom := Image1.ClientHeight * 1440 div LogY;
rcPage := rc;
LastChar := 0;
MaxLen := GetTextLen;
chrg.cpMax := -1;
repeat
chrg.cpMin := LastChar;
LastChar := SendMessage(RichEdit1.Handle, EM_FORMATRANGE, 1,
Longint(@Range));
until (LastChar >= MaxLen) or (LastChar = -1);
end;
SendMessage(RichEdit1.Handle, EM_FORMATRANGE, 0, 0);
Image1.Refresh;
end;
 
thanks,you are right!but
maxlen作用何在?
 
maxlen判断字符长度
 
接受答案了.
 
后退
顶部