打印vRichEdit到一ACanvas的ARect上:
var
Range: TFormatRange;
OldMap: Integer;
begin
FillChar(Range, SizeOf(TFormatRange), 0);
with Rangedo
begin
hdc := ACanvas.Handle;
hdcTarget := hdc;
rc.left := ARect.Left * 1440 div REPORTDPI;
rc.top := ARect.Top * 1440 div REPORTDPI;
rc.right := ARect.Right * 1440 div REPORTDPI;
rc.bottom := ARect.Bottom * 1440 div REPORTDPI;
rcPage := ARect;
chrg.cpMax := -1;
OldMap := SetMapMode(hdc, MM_TEXT);
SendMessage(vRichEdit.Handle, EM_FORMATRANGE, 0, 0);
SendMessage(vRichEdit.Handle, EM_DISPLAYBAND, 0, Longint(@ARect));
try
chrg.cpMin := 0;
SendMessage(vRichEdit.Handle, EM_FORMATRANGE, 1, Longint(@Range));
finally
SendMessage(vRichEdit.Handle, EM_FORMATRANGE, 0, 0);
SetMapMode(hdc, OldMap);
end;
end;
vRichEdit.Free;
end;
才50分,太小气了,我好辛苦才在自己的项目中写出这方法的。你50小分就吃了,没天理!