如何取得系统字体大小的列表,我想做一个选字体大小的下拉框?
解决方案 »
- 帮看一下我写的代码为什么不行,谢谢
- StringGride
- 组件模板的动态生成。
- 征集新年祝福公司客户的用词,(写在贺卡和礼物上的)!
- 哪里有delphi5/6/7下载?中/英版。没分了,给十分先。
- 关于TQuery的问题
- 我的d6不能保存project,提示'@' is not a valid identifier?
- BoldForDelphi 怎麼刷新數據!!!(急急急)
- *************在关闭计算机或重启计算机的时候,怎样执行DELPHI程序里的ONCLOSE事件呢*****************
- 谁能帮我把delphi一个文件转换成VC给100分
- 网络UDP数据包的发送和接收
- 关于ADOTable,ADOQuery,ADODateset!
WWW。51DELPHI。COM里有下载
放置1个button1 和 listbox1,
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
str:string;
begin
listbox1.Items.Clear;
for i:=0 to screen.fonts.Count-1 do
begin
str:=screen.fonts.strings[i];
if str[1]<>'@' then
begin
if ord(str[1])>=128 then
begin
Listbox1.Items.Add(str);
continue;
end;
end
else
begin
if ord(str[2])>=128 then
begin
Listbox1.Items.Add(str);
continue;
end;
end; end;
end;
FontType: Integer; Data: Pointer): Integer; stdcall;
begin
TStrings( Data ).Add(IntToStr( LogFont.lfHeight) );
Result := 1;
end;procedure GetFontSizeList( FontName : String; List : TStrings );
//FontName,是字体名;
//这种字体的所有可用尺寸将被填在List中。
var
DC: HDC;
begin
List.Clear;
DC := GetDC(0);
EnumFonts(DC, PChar(FontName), @EnumFontsSize, Pointer(List));
ReleaseDC(0, DC);
end;///////////////////////////////////////////////////////////////////
var
Form1: TForm1;
VRES:Integer;const
MaxStdSizes=16;function EnumFontFamiliesProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
FontType: Integer; Data:Pointer): Integer; {$IFDEF WIN32} stdcall; {$ELSE} export; {$ENDIF} procedure AddToList(const aValue:String);
var
j:Integer;
c:Boolean;
begin
j:=0;
c:=False;
with TListBox(Data) do
begin
while (j<Items.Count) and not c do
if StrToInt(aValue)>=StrToInt(Items[j]) then Inc(j) else c:=True;
Items.Insert(j, aValue);
end;
end;var
i:Integer;
c:String;
const
csizes:array[0..MaxStdSizes-1] of Integer=(8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72);begin
result:=0;
with TListBox(Data) do
begin
if (FontType and TRUETYPE_FONTTYPE=TRUETYPE_FONTTYPE) or (FontType in [0,2]) then
begin
For i:=0 to (MaxStdSizes-1) do Items.Add(IntToStr(Csizes[i]));
result:=0
end; if (FontType and RASTER_FONTTYPE=RASTER_FONTTYPE)
{or (FontType and DEVICE_FONTTYPE=DEVICE_FONTTYPE)} then
with TextMetric do
begin
c:=IntToStr(Round((tmHeight-tmInternalLeading)*72 / VRES));
if Items.IndexOf(c)=-1 then AddToList(c);
result:=1;
end;
end
end;procedure TForm1.DoList(FFontName:String);
var
buffer:array[0..255] of Char;
DC:HDC;
begin
ListBox1.Items.Clear; DC:=GetDC(0);
StrPCopy(Buffer, FFontName);
vres:=GetDeviceCaps(DC, LOGPIXELSY);
EnumFontFamilies(DC, Buffer, @EnumFontFamiliesProc,
LongInt(ListBox1));
ReleaseDC(0, DC);
end;