unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TMainForm = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var MainForm: TMainForm;implementation uses TypInfo;{$R *.dfm}procedure TMainForm.Button1Click(Sender: TObject); var I: Integer; begin for I := 0 to 3 do if Byte(Canvas.Font.Style) and (1 shl I) <> 0 then ShowMessage(GetEnumName(TypeInfo(TFontStyle), I)); end;procedure TMainForm.FormCreate(Sender: TObject); begin Canvas.Font.Style := [fsItalic, fsUnderLine]; end;end.
var h,l,i:integer;s:string; begin l:=ord(low(TFontStyle)); h:=ord(high(TFontStyle)); for i:=l to h do begin s:=GetEnumName(typeinfo(TFontStyle),i); self.ListBox1.Items.Append(s); end; end;
listbox1.items.add('粗体');
if fsitalic in font.style then
listbox1.items.add('斜体');
...
记忆里应该只这样的!!希望你能看懂!!:)
我不懂!我不想和你多说什么!
你自己去试试我的程序就知道谁不懂了!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TMainForm = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
MainForm: TMainForm;implementation
uses TypInfo;{$R *.dfm}procedure TMainForm.Button1Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to 3 do
if Byte(Canvas.Font.Style) and (1 shl I) <> 0 then
ShowMessage(GetEnumName(TypeInfo(TFontStyle), I));
end;procedure TMainForm.FormCreate(Sender: TObject);
begin
Canvas.Font.Style := [fsItalic, fsUnderLine];
end;end.
begin
l:=ord(low(TFontStyle));
h:=ord(high(TFontStyle));
for i:=l to h do
begin
s:=GetEnumName(typeinfo(TFontStyle),i);
self.ListBox1.Items.Append(s);
end;
end;
GetEnumName是个什么函数?
在typinfo.pas中