TextOut()??(100分)

  • 主题发起人 主题发起人 alamo
  • 开始时间 开始时间
A

alamo

Unregistered / Unconfirmed
GUEST, unregistred user!
在delphi中用TextOut()写字,
可是然如何竖着写字呢?字体也要转向。
 
procedure AngleTextOut(CV: TCanvas; const sText: String; x, y, angle:integer;color:TColor);
var
LogFont: TLogFont;
MyFont,SaveFont: TFont;
begin
SaveFont := TFont.Create;
SaveFont.Assign(CV.Font);
MyFont:= SaveFont;
MyFont.Style := [fsBold];
MyFont.Name := 'Times New Roman';
GetObject(MyFont.Handle, sizeof(TLogFont), @LogFont);
with LogFont do
begin
lfEscapement := angle *10;
lfPitchAndFamily := FIXED_PITCH or FF_DONTCARE;
lfQuality := PROOF_QUALITY;
lfHeight:=30;
//lfStrikeOut := 1;
end; {with}
CV.Font.Handle := CreateFontIndirect(LogFont);
CV.Font.Color := color;
SetBkMode(CV.Handle, TRANSPARENT);
CV.TextOut(x, y, sText);
CV.Font.Assign(SaveFont);
SaveFont.Free;
end;
调用时:
AngleTextOut(Canvas,'LAN EXPLORER',14, 229, 90,clRed);
 
procedure TForm1.Button1Click(Sender: TObject);
var lf:tlogfont;
tf:tfont;
begin
tf:=tfont.Create;
tf.Assign(button1.font);
getobject(tf.handle,sizeof(lf),@lf);
lf.lfEscapement:=450;
lf.lfOrientation:=450;
tf.Handle:=createfontindirect(lf);
button1.parentfont:=false;
button1.Font.Assign(tf);
tf.free;
end;
 
整个一句的输出我没搞定,我用的是一个一个字的输出.
s:='大富翁论坛';
for i:=0 to (Length(S) div 2) do
begin
S1:=S[2*I-1]+S[2*I];
Obj.Canvas.TextOut(2,I*20-8,S1);
end;
得到的效果: 大



 
var lf:tlogfont;
tf:tfont;
begin
with form1.canvas do
begin
font.name:=‘黑体';
font.size:=24;
tf:=tfont.create;
tf.assign(font);
getobject(tf.handle,sizeof(lf),@lf);
lf.lfescapement:=450;
lf.lforientation:=450;
tf.handle:=createfontindirect(lf);
font.assign(tf);
tf.free;
textout(20,height div 2 ,'旋转字体!');
end;
end;
 
多人接受答案了。
 
后退
顶部