首页  编辑  

Windows菜单字体的设置和恢复

Tags: /超级猛料/OS.操作系统/   Date Created:

Windows菜单字体的设置和恢复

{ Returns menu font size }

function GetMenuFontSize: Integer;

var

 ncm: TNonClientMetrics;

 PixelsPerInch: integer;

begin

 ncm.cbSize := sizeof(TNonClientMetrics);

 SystemParametersInfo(

   SPI_GETNONCLIENTMETRICS,

   sizeof(NONCLIENTMETRICS),

   @ncm,

   SPIF_UPDATEINIFILE

 );

 PixelsPerInch := GetDeviceCaps(GetDC(0), LOGPIXELSY);

 Result := -MulDiv(ncm.lfMenuFont.lfHeight, 72, PixelsPerInch);

end;

{ Set menu font size }

procedure SetMenuFontSize(FontSize: Integer);

var

 ncm: TNonClientMetrics;

 PixelsPerInch: Integer;

begin

 ncm.cbSize := sizeof(TNonClientMetrics);

 SystemParametersInfo(

   SPI_GETNONCLIENTMETRICS,

   sizeof(NONCLIENTMETRICS),

   @ncm,

   0

 );

 PixelsPerInch := GetDeviceCaps(GetDC(0), LOGPIXELSY);

 ncm.lfMenuFont.lfHeight := -MulDiv(FontSize, PixelsPerInch, 72);

 SystemParametersInfo(

   SPI_SETNONCLIENTMETRICS,

   sizeof(NONCLIENTMETRICS),

   @ncm,

   SPIF_UPDATEINIFILE

 );

end;