代码文件:


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. mysql类型转换函数convert与cast的用法,及SQL server的区别

    首先,convert函数 字符集转换 :   CONVERT(xxx  USING   gb2312) 类型转换和SQL Server一样,不过类型参数上有不同: CAST(xxx  AS   类型) ...

  2. redis-config.properties属性资源文件

    redis.host=192.168.200.128redis.port=6379redis.pass=redis.database=0redis.maxIdle=300redis.maxWait=3 ...

  3. linux IPC的信号量

    信号量相关函数原型 获得一个信号量ID #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h&g ...

  4. Shiro学习(21)授予身份及切换身份

    在一些场景中,比如某个领导因为一些原因不能进行登录网站进行一些操作,他想把他网站上的工作委托给他的秘书,但是他不想把帐号/密码告诉他秘书,只是想把工作委托给他:此时和我们可以使用Shiro的RunAs ...

  5. CSS:CSS 盒子模型

    ylbtech-CSS:CSS 盒子模型 1.返回顶部 1. CSS 盒子模型 CSS 盒子模型(Box Model) 所有HTML元素可以看作盒子,在CSS中,"box model&quo ...

  6. bigdecimal解决小数间的加减乘除

    public class bigdecimal { public static BigDecimal div(double v1,double v2){ BigDecimal b1=new BigDe ...

  7. 我看Spring MVC系列(一)

    1.Spring MVC是什么: Spring MVC:Spring框架提供了构建Web应用程序的全功能MVC模块. 2.Spring helloWorld应用(基于Spring 4.2) 1.添加S ...

  8. nginx新增简单下载站点

    配置nginx server { autoindex on;# 显示目录 autoindex_exact_size on;# 显示文件大小 autoindex_localtime on;# 显示文件时 ...

  9. MySql 主从复制及深入了解

    分享一个不错的mysql文章 https://segmentfault.com/a/1190000008942618

  10. 冲上云霄,Dubbo Go!

    来源:开源中国社区 5 月 21 日,经过一年多的孵化,Apache Dubbo 从 Apache 软件基金会毕业,成为 Apache 顶级项目.推荐:厉害了,Dubbo 正式毕业! Dubbo 是阿 ...