代码文件:


unit Unit1;

interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, CheckLst; type
  TForm1 = class(TForm)
    CheckListBox1: TCheckListBox;
    procedure FormPaint(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure CheckListBox1Click(Sender: TObject);
  end; var
  Form1: TForm1; implementation{$R *.dfm}uses GDIPOBJ, GDIPAPI; var fs: Integer; procedure TForm1.CheckListBox1Click(Sender: TObject);
const
  fsArr: array[..] of Integer = (FontStyleRegular,
                                  FontStyleBold,
                                  FontStyleItalic,
                                  FontStyleBoldItalic,
                                  FontStyleUnderline,
                                  FontStyleStrikeout);
var
  i: Integer;
begin
  fs := ;
  for i := to CheckListBox1.Items.Count - do
    if CheckListBox1.Checked[i] then
      fs := fs or fsArr[i];
  Repaint;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
  CheckListBox1.Align := alLeft;
  CheckListBox1.Items.CommaText := 'FontStyleRegular,' +
                                  'FontStyleBold,' +
                                  'FontStyleItalic,' +
                                  'FontStyleBoldItalic,' +
                                  'FontStyleUnderline,' +
                                  'FontStyleStrikeout';
  CheckListBox1.Checked[] := True;
end; procedure TForm1.FormPaint(Sender: TObject);
var
  g: TGPGraphics;
  sb: TGPSolidBrush;
  font: TGPFont;
begin
  g := TGPGraphics.Create(Canvas.Handle);
  sb := TGPSolidBrush.Create(aclRed);   font := TGPFont.Create('微软雅黑', , fs);
  g.DrawString('Delphi', -, font, MakePoint(CheckListBox1.Width + 0.0, ), sb);   font.Free;
  sb.Free;
  g.Free;
end; end.

窗体文件:


object Form1: TForm1
  Left =
  Top =
  Caption = 'Form1'
  ClientHeight =
  ClientWidth =
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poDesktopCenter
  OnCreate = FormCreate
  OnPaint = FormPaint
  PixelsPerInch =
  TextHeight =
  object CheckListBox1: TCheckListBox
    Left =
    Top =
    Width =
    Height =
    ItemHeight =
    TabOrder =
    OnClick = CheckListBox1Click
  endend

文本样式的定义:


FontStyle = Integer;
const
  FontStyleRegular    = Integer(); {普通文本}
  FontStyleBold      = Integer(); {加粗文本}
  FontStyleItalic    = Integer(); {倾斜文本}
  FontStyleBoldItalic = Integer(); {加粗并倾斜文本}
  FontStyleUnderline  = Integer(); {带下划线的文本}
  FontStyleStrikeout  = Integer(); {中间有直线通过的文本}
Type
TFontStyle = FontStyle;

再学 GDI+文本输出文本样式的更多相关文章

  1. VS2010/MFC编程入门之四十七(字体和文本输出:CFont字体类)

    上一节中鸡啄米讲了MFC异常处理,本节的主要内容是字体CFont类. 字体简介 GDI(Graphics Device Interface),图形设备接口,是Windows提供的一些函数和结构,用于在 ...

  2. VS2010-MFC(字体和文本输出:CFont字体类)

    转自:http://www.jizhuomi.com/software/239.html 字体简介 GDI(Graphics Device Interface),图形设备接口,是Windows提供的一 ...

  3. Directx11教程(66) D3D11屏幕文本输出(1)

    原文:Directx11教程(66) D3D11屏幕文本输出(1)      在D3D10中,通过ID3DX10Font接口对象,我们可以方便的在屏幕上输出文字信息,一个DrawText函数就能解决所 ...

  4. Windows程序设计(第五版)学习:第四章 文本输出

    第四章 文本输出 1,客户区:整个应用程序窗口中没有被标题栏.边框.菜单栏.工具栏.状态栏和滚动条占用的区域.简而言之,客户区就是窗口中程序可以在上面绘制并向用户传达可视化信息的区域.   2,大多数 ...

  5. MFC字体与文本输出

    字体 成员函数 1.CFont( ); 构造一个CFont对象.此对象在使用之前应该先使用CreateFont.CreateFontIndirect.CreatePointFont或CreatePoi ...

  6. 《windows程序设计》学习_4:文本输出,加滚动条

    //总行数 #define NUMLINES ((int) (sizeof sysmetrics / sizeof sysmetrics [0])) struct { int Index ; TCHA ...

  7. VS2010/MFC字体和文本输出:文本输出

    字体和文本输出:文本输出 本节主要讲解文本输出的方法和实例. 文本输出过程 在文本输出到设备以前,我们需要确定字体.字体颜色和输出的文本内容等信息.Windows窗口的客户区由应用程序管理,所以我们还 ...

  8. VS2010/MFC编程入门之四十八(字体和文本输出:文本输出)

    鸡啄米在上一节中讲了CFont字体类,本节主要讲解文本输出的方法和实例. 文本输出过程 在文本输出到设备以前,我们需要确定字体.字体颜色和输出的文本内容等信息.Windows窗口的客户区由应用程序管理 ...

  9. Direct3D 10学习笔记(三)——文本输出

    本篇将简单整理Direct3D 10的文本输出的实现,具体内容参照< Introduction to 3D Game Programming with DirectX 10>(中文版有汤毅 ...

随机推荐

  1. 分考场(np完全问题,回溯法)

    问题描述 n个人参加某项特殊考试. 为了公平,要求任何两个认识的人不能分在同一个考场. 求是少需要分几个考场才能满足条件. 输入格式 第一行,一个整数n(1<n<100),表示参加考试的人 ...

  2. mybatis 多表查询sql

    在使用spring,spring mvc,mybatis时,mybatis链接数据库做多表查询的时候,sql语句中直接使用left join等链接字符就可以 链接多个表,参数类型是parameterT ...

  3. JavaIO流之字节流

    什么是字节? 所谓字节(Byte),是计算机数据存储的一种计量单位.一个二进制位称为比特(bit),8个比特组成一个字节,也就是说一个字节可以用于区分256个整数(0~255).由此我们可以知道,字节 ...

  4. python3 投票

    import urllib.request # cd C:\Python36-32\Scripts # pip install BeautifulSoup from bs4 import Beauti ...

  5. linux环境下安装PHP的OpenSSL扩展

    先安装依赖包:yum install openssl openssl-devel 进入PHP安装包里的OpenSSL文件夹,根据个人的安装包位置不同,此处是 cd /home/local/php.5. ...

  6. 虚拟机安装(Cent OS)

    转载:http://www.cnblogs.com/kkdd-2013/p/3973807.html 0 前言 本篇主要介绍在虚拟机VMware上安装CentOS6.5的过程,并且在自己电脑上安装成功 ...

  7. Linux权限简析

  8. spring boot开发,jar包一个一个来启动太麻烦了,写一个bat文件一键启动

    spring boot开发,jar包一个一个来启动太麻烦了,写一个bat文件一键启动 @echo offcd D:\workProject\bushustart cmd /c "title ...

  9. HA配置

    主T800 eth0 192.168.2.32备T600 eth1 192.168.2.33安装nginx yum install -y nginx 关闭主备的防火墙iptables.selinux ...

  10. 专题:LFS构建逻辑理解

    严格来说,LFS只能称为“pseudo LFS”,WHY? 因为LFS归根结底,还是基于已有的操作系统平台构建而来,并非真正的从0开始,它没有突破所谓“鸡与蛋”的死循环:但它确实有助于理解Linux的 ...