添加字体资源

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
AddFontResource(PChar('myfont.ttf'));
SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);
uses Registry;
procedure TForm1.Button1Click(Sender: TObject);
var
reg: TRegistry;
b : bool;
begin
CopyFile('C:.TTF',
'C:.TTF', b);
reg := TRegistry.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.LazyWrite := false;
reg.OpenKey('Software',
false);
reg.WriteString('TESTMICR (TrueType)','FP000100.TTF');
reg.CloseKey;
reg.free;
{Add the font resource}
AddFontResource('c:.TTF');
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
{Remove the resource lock}
RemoveFontResource('c:.TTF');
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
end;
***************************
使用没有注册的字体资源:
procedure TForm1.FormCreate(Sender: TObject);
begin
AddFontResource(PChar(ExtractFilePath(ParamStr(0) + 'YourFont.TTF')));
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
end;
 
procedure TForm1.FormDestroy(Sender: TObject);
begin
RemoveFontResource(PChar(ExtractFilePath(ParamStr(0) + 'YourFont.TTF')));
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
end;
 

Similar threads

S
回复
0
查看
700
SUNSTONE的Delphi笔记
S
S
回复
0
查看
694
SUNSTONE的Delphi笔记
S
S
回复
0
查看
795
SUNSTONE的Delphi笔记
S
S
回复
0
查看
758
SUNSTONE的Delphi笔记
S
I
回复
0
查看
537
import
I
后退
顶部