zoukankan      html  css  js  c++  java
  • 转载:Delphi利用Windows GDI实现文字倾斜

    Delphi利用Windows GDI实现文字倾斜 

    https://my.oschina.net/u/582827/blog/232720

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
      Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
    
    type
      TForm1 = class(TForm)
        procedure FormPaint(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.FormPaint(Sender: TObject);
    var
      FLogFont: tagLogFontW;
      hTempFont, hPrevFont: HFONT; //字体句柄
      hTempDC: HDC; //设备描述表或图形设备句柄
      TempString: string; //输出的文字
    begin
      FLogFont.lfHeight := 10; //字高
      FLogFont.lfWidth := 10; //字宽
      FLogFont.lfWeight := 1;  //字体笔划粗细程度
      FLogFont.lfUnderline := 0; //没有下划线
      FLogFont.lfStrikeOut := 0; //没有删除线
      FLogFont.lfItalic := 0; //斜体效果否
      FLogFont.lfCharSet := GB2312_CHARSET; //字符集
      FLogFont.lfEscapement := 450; //倾斜度
      // FLogFont.lfOrientation := 450;  //方向与倾斜度取值同
      FLogFont.lfFaceName := '宋体'; //字体名称
      //创建逻辑字体
      hTempFont := CreateFontIndirect(FLogFont);
      TempString := '测试';
    
      hTempDC := GetDC(Handle); //取出窗口设备的当前字体,并替换为新字体
      hPrevFont := SelectObject(hTempDC, hTempFont); //设置设备窗口的文字色彩
      SetTextColor(hTempDC, clRed);
      TextOut(hTempDC, 20, 50, PChar(TempString), Length(TempString));
      SelectObject(hTempDC, hPrevFont);
      DeleteObject(hTempFont);
      ReleaseDC(Handle, hTempDC);
    end;
    
    end.
    View Code

    //可以将Form1.Color = clWhite 这样Form的背景就和字体的背景一样,这样看起来效果好一些;

  • 相关阅读:
    pause
    vim 修改复制过来的代码缩进
    解决TeamViewer提示商业用途
    服务器上安装解决ole错误
    vs密匙
    oracle11g忘记管理员密码
    sql同时删除多个表的数据
    删除表中多余的重复记录(多个字段),只留有rowid最小的记录
    查找表中多余的重复记录(多个字段)
    删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录
  • 原文地址:https://www.cnblogs.com/studycode/p/11651432.html
Copyright © 2011-2022 走看看