Trying to change the menu fonts and dialog box to Arial in MFC

Hi,

We are trying to change the menu fonts to Arial in MFC i.e. changing the fonts of File, Edit etc options to Arial from the font set by default. I tried to do this in the OnCreate function by doing it this way

NONCLIENTMETRICS ncm = { sizeof(NONCLIENTMETRICS) };

bool x = ::SystemParametersInfo (
SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
&ncm, false );

if(x == false)
DWORD d = GetLastError();

strcpy(ncm.lfCaptionFont.lfFaceName, "Arial");
strcpy(ncm.lfSmCaptionFont.lfFaceName, "Arial");
strcpy(ncm.lfMenuFont.lfFaceName, "Arial");
strcpy(ncm.lfStatusFont.lfFaceName, "Arial");
strcpy(ncm.lfMessageFont.lfFaceName, "Arial");

::SystemParametersInfo (
SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
&ncm, SPIF_SENDCHANGE );

However I dont think this is correct to way to do it. Could somone shed some light on how to do this.

Thanks.




Answer this question

Trying to change the menu fonts and dialog box to Arial in MFC

  • tssweb

    If you want to change the font of a menu, you have to create an owner-draw one and override DrawItem() at least.

  • Builty

    in addition to marius comment, please check this link to see some examples.

  • Trying to change the menu fonts and dialog box to Arial in MFC