M
majorsoft
Unregistered / Unconfirmed
GUEST, unregistred user!
我在程序中动态设置image1.width以至image1的长度略大于画出来的字符串长度。
...
edt_content.Font.Size:=32;
image1.width:=round(edt_content.Font.Size*(length(edt_content.Text) div 2 +1 ) *1.2);//字体大小*1.2=字体长度
with image1.Canvas do
begin
Brush.Color:=clBlack;
FillRect(rect(0,0,image1.Width,image1.height));
Font.Color:=clYellow;
Font.Size:=edt_content.Font.Size;
Textout(0,0,edt_content.Text);
end;
end;
我用下面的程序来测试image1的长度,发现 image1的长度是够的,但字符串不能完整地显示,不知道是Canvas的bug,还是程序写法有问题?
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
statusBar1.Panels[1].Text:='move on image'+inttostr(x)+':'+inttostr;
end;
...
edt_content.Font.Size:=32;
image1.width:=round(edt_content.Font.Size*(length(edt_content.Text) div 2 +1 ) *1.2);//字体大小*1.2=字体长度
with image1.Canvas do
begin
Brush.Color:=clBlack;
FillRect(rect(0,0,image1.Width,image1.height));
Font.Color:=clYellow;
Font.Size:=edt_content.Font.Size;
Textout(0,0,edt_content.Text);
end;
end;
我用下面的程序来测试image1的长度,发现 image1的长度是够的,但字符串不能完整地显示,不知道是Canvas的bug,还是程序写法有问题?
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
statusBar1.Panels[1].Text:='move on image'+inttostr(x)+':'+inttostr;
end;