zoukankan      html  css  js  c++  java
  • WinAPI: GetCharWidth 和 GetCharWidth32 获取字符宽度

    //声明:
    GetCharWidth(
      DC: HDC;                   {设备环境句柄}
      FirstChar, LastChar: UINT; {范围内的第一个和最后一个字符值}
      const Widths               {接受每个字符宽度值的整型数组}
    ): BOOL;
    
    GetCharWidth32(
      DC: HDC;                   {设备环境句柄}
      FirstChar, LastChar: UINT; {范围内的第一个和最后一个字符值}
      const Widths               {接受每个字符宽度值的整型数组}
    ): BOOL;
    
    {GetCharWidth32 专用于 Win32 系统, 在这里和 GetCharWidth 没有区别}
    
    //获取当前字体所有大写字母的宽度(用 Memo 显示) procedure TForm1.FormCreate(Sender: TObject); var arr: array[0..25] of Integer; i: Integer; begin GetCharWidth(Canvas.Handle, Ord('A'), Ord('Z'), arr); //GetCharWidth32(Canvas.Handle, Ord('A'), Ord('Z'), arr); {也可} Memo1.Clear; for i := 0 to 25 do begin Memo1.Lines.Add(Char(Ord('A')+i) + #9 + IntToStr(arr[i])); end; end;
    //效果图:

  • 相关阅读:
    2101 可达性统计
    POJ1179 Polygon
    POJ1015 Jury Compromise
    读入输出优化
    队列优化dijsktra(SPFA)的玄学优化
    5104 I-country
    CH5102 Mobile Service
    P1005 矩阵取数游戏
    (模板)线段树2
    POJ3666 Making the Grade
  • 原文地址:https://www.cnblogs.com/del/p/1066230.html
Copyright © 2011-2022 走看看