📄 getcharwidthsu.pas
字号:
unit GetCharWidthsU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Label1: TLabel;
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormActivate(Sender: TObject);
var
CharWidths: array[0..25] of Integer; // holds the character widths
Count: Integer; // general loop control variable
begin
{initialize the string grid}
StringGrid1.Cells[0,0] := 'Character';
StringGrid1.Cells[1,0] := 'Width';
{retrieve the widths of all uppercase letters}
GetCharWidth(Form1.Canvas.Handle, Ord('A'), Ord('Z'), CharWidths);
{display the character widths}
for Count := 0 to 26 do
begin
StringGrid1.Cells[0, Count+1] := Char(Ord('A')+Count);
StringGrid1.Cells[1, Count+1] := IntToStr(CharWidths[Count]);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -