delphi 如何把字体颜色保存到数据库

2025-04-08 07:23:08

1、用记事本打开dfm文件会看到类似这样的文本:object Label1: TLabelLeft = 24Top = 32Width = 140Height = 46Caption = #20445#23384#23454#20363Font.Charset = GB2312_CHARSETFont.Color = clBlueFont.Height = -35Font.Name = #24494#36719#38597#40657Font.Style = [fsBold, fsUnderline, fsStrikeOut]ParentFont = Falseend

delphi 如何把字体颜色保存到数据库

2、自己写了个直接保存成文件文件的,记录一下unit Font2String;interfaceuses潮贾篡绐Classes, SysUtils, Dialogs, Graphics;function Font2File(AFont: TFont; APath: string): Boolean;function File2Font(APath: string; AFont: TFont): Boolean;implementationfunction Font2File(AFont: TFont; APath: string): Boolean;varFD: TFontDialog;beginResult := False;FD := TFontDialog.Create(nil);tryFD.Font.Assign(AFont);WriteComponentResFile(APath, FD);Result := True;finallyFD.Free;end;end;

delphi 如何把字体颜色保存到数据库

3、function File2Font(APath: string; AFont: TFont): Boolean;varFD: TFontDialog;beginResult := False;FD := TFontDialog.Create(nil);tryReadComponentResFile(APath, FD);//如果此外为nil,下面的注册去掉AFont.Assign(FD.Font);Result := True;finallyFD.Free;end;end;

delphi 如何把字体颜色保存到数据库

4、//initialization//RegisterClass(TFontDialog);end.

delphi 如何把字体颜色保存到数据库

5、例子:procedure TForm1.Button1Click(Sender: TObject);beginFont2File(Label1.Font, 'd:\Font.fnt');//把字体保存成文件end;procedure TForm1.Button2Click(Sender: TObject);beginFile2Font( 'd:\Font.fnt', Label2.Font);//从文件里读取字体end;

delphi 如何把字体颜色保存到数据库
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢