16,748
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.btn1Click(Sender: TObject);
var
R: TRect;
S: string;
temp: array[0..50] of Char;
begin
R := Rect(20, 20, 150, 30);
S := 'This is a very long string which will' +
'run into multiple lines of text.';
{ 采用StrPCopy函数转化string类型为PChar类型}
DrawText(Canvas.Handle, StrPCopy(temp, S), -1, R, DT_CALCRECT or DT_WORDBREAK);
Canvas.Brush.Style := bsSolid;
Canvas.Rectangle(R);
Canvas.Brush.Style := bsClear;
DrawText(Canvas.Handle, StrPCopy(temp, S), -1, R, DT_WORDBREAK);
end;