procedure TSkinEdit.SetFont(nPointSize: Integer; FontName:
String; FontStyle: TFontStyle;
AktForecolor, InAktForecolor: COLORREF; Shadow: Boolean; ShadowOffset: Single);
var
Fam: GpFontFamily;
Gpf: GpFont;
Graphics: LONG_PTR;
DC: HDC;
lf: LOGFONTW;
begin
Graphics := 0;
Gpf :=
nil;
Fam :=
nil;
if Handle <> 0
then
begin
FShadow := Shadow;
FShadowColor := ShadowColor;
FShadowOffset := ShadowOffset;
FAktForecolor := AktForecolor;
FInAktForecolor := InAktForecolor;
FPointSize := nPointSize;
FFontName := FontName;
FFontStyle := FontStyle;
DC := GetDC(0);
try
if GdipCheck(GdipCreateFromHDC(
DC, Graphics)) = OK
then
begin
if GdipCheck(GdipCreateFontFamilyFromName(PWideChar(FFontName),
nil, Fam)) = OK
then
begin
if assigned(Fam)
then
begin
GdipCheck(GdipCreateFont(Fam, FPointSize, FontStyle, 2, Gpf));
if assigned(Gpf)
then
begin
GdipCheck(GdipGetLogFontW(Gpf, Graphics, lf));
_hfont := CreateFontIndirectW(lf);
SendMessageW(
Handle, WM_SETFONT, WPARAM(_hfont), 0);
end;
end;
end;
end;
finally
ReleaseDC(0,
DC);
if Graphics <> 0
then
GdipCheck(GdipDeleteGraphics(Graphics));
if assigned(Gpf)
then
GdipCheck(GdipDeleteFont(Gpf));
if assigned(Fam)
then
GdipCheck(GdipDeleteFontFamily(Fam));
end;
end;
end;