如何判断一个字符串占多少像素 ,又相关的函数么比如800*600的显示器上判断一列字符在屏幕上占的的宽度,随便什么字体,就是看看有没有什么方法
解决方案 »
- 请问swf控件的PopupMenu属性怎么用,貌似本身的右键菜单替换不掉
- 保存数据的bug,挺郁闷的~~~
- 如何在msSQL2000中通过create table给字段加入“描述”信息
- 也就这么回事,散.
- delphi播放声音文件的问题,大家来看一下!
- 组件服务中的Application应用程序在系统管理组件时起什么作用
- i/o error 104 //100分
- 创建了一个远程数据模块,如何可以在客户端数据请求完成以后,将远程数据模块也关闭。
- 请教高手枚举窗口的问题..
- 一个简单问题,却不知道怎么搞的?数据问题
- 将SQL表数据插入到VForpro表中 很急先谢了(100分)不够在加!!
- InstallShield Express问题!在线等待!
用一个循环扫描一下就可以知道结果了
呵呵~~~
i: Integer;
begin
with PageControl1 do
begin
for i := 0 to PageCount - 1 do
begin
if (Canvas.TextWidth(Pages[i].Caption) * 2) > TabWidth then
TabWidth := Canvas.TextWidth(Pages[i].Caption) * 2;
if (Canvas.TextHeight(Pages[i].Caption) * 2) > TabHeight then
TabHeight := Canvas.TextHeight(Pages[i].Caption) * 2;
end; end;
end;
function TextWidth(const Text: WideString): Integer;DescriptionUse TextWidth to determine the length a string will occupy in the image. TextWidth indicates whether a given string will fit in the available space. Other graphical elements in the image such as lines, or additional strings can be positioned to accommodate the width of the text.TextWidth returns the same value as TextExtent(Text).cx.
//self.Canvas.Font.Name:='宋体'; //设置字体
//self.Canvas.Font.Size:=20; //字体大小
iHeight:=self.Canvas.TextHeight('1234567');
iWidth:=self.Canvas.TextWidth('1234567'); ShowMessage('H:'+IntToStr(iHeight)+#13+'W:'+IntToStr(iWidth));
end;