呵呵,一个小过程:
procedure TextOutAngle(x,y,aAngle,aSize: integer; txt: string;ACanvas:TCanvas);
// 坐标、角度、大小,内容,输出的Canvas
var hFont, Fontold: integer;
DC: hdc;
Fontname: string;
begin
if length(txt)= 0 then
EXIT;
DC:= ACanvas.handle;
SetBkMode(DC, transparent);
Fontname:= ACanvas.Font.Name;
hFont:= CreateFont(-aSize,0, aAngle*10,0, fw_normal,0, 0,
0,1,4,$10,2,4,PChar(Fontname));
Fontold:= SelectObject(DC, hFont);
TextOut(DC,x,y,PChar(txt), length(txt));
SelectObject(DC, Fontold);
DeleteObject(hFont);
end;
使用:
procedure TForm1.Button1Click(Sender: TObject);
begin
TextOutAngle(100,100,40,12,'This is a demo',PaintBox1.Canvas);
end;
注意:你的PaintBox的字体必须要设成TrueType或是OpenType的字体才行!就是字体选择框
中有“TT”或是“O”字样的那种。象“宋体”“Arial”之类的。