再学GDI+[39]: 文本输出

本例效果图:

代码文件:unit Unit1;
interface
uses
 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[0..5] of Integer = (FontStyleRegular,
                  FontStyleBold,
                  FontStyleItalic,
                  FontStyleBoldItalic,
                  FontStyleUnderline,
                  FontStyleStrikeout);
var
 i: Integer;
begin
 fs := 0;
 for i := 0 to CheckListBox1.Items.Count - 1 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[0] := 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('微软雅黑', 50, fs);
 g.DrawString('Delphi', -1, font, MakePoint(CheckListBox1.Width + 0.0, 0), sb);
 font.Free;
 sb.Free;
 g.Free;
end;
end.

时间: 2024-12-31 19:41:06

再学GDI+[39]: 文本输出的相关文章

再学GDI+[41]: 文本输出

本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormPaint(Sender: TObject); procedure FormClick(Sender: TObject); end; var Form1: TForm1;

再学GDI+[38]: 文本输出

本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure But

再学GDI+[45]: 文本输出

本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls; type TForm1 = class(TForm) RadioGroup1: TRadioGroup; RadioGroup2: TRadioGroup; RadioGroup3: TRadi

再学GDI+[44]: 文本输出

本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) ListBox1: TListBox; procedure FormPaint(Sender: TObject); procedure FormCreate(Sender: TOb

再学GDI+[43]: 文本输出

这比用 Screen.Fonts; 获取麻烦一些. 本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; procedure FormCreate(Sender: TObject); end; var Fo

再学GDI+[42]: 文本输出

本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls; type TForm1 = class(TForm) RadioGroup1: TRadioGroup; TrackBar1: TTrackBar; procedure FormCreate(S

再学GDI+[40]: 文本输出

本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, CheckLst; type TForm1 = class(TForm) RadioGroup1: TRadioGroup; procedure FormCreate(Sender: TObject); proce

再学GDI+[99]: TGPImage(19)

本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) OpenDialog1: TOpenDialog; Button1: TButton; Button2: TButton; procedure FormCrea

再学GDI+[97]: TGPImage(17)

获取GDI+所支持的可编码.可解码的图像格式 其实这和 TGPImage 是没有关系的. 本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; procedure FormCreate(Sender: TO