'폰트변경'에 해당되는 글 1건

  1. 2009.09.30 [MFC] 리스트 컨트롤 폰트 바꾸기
2009. 9. 30. 10:13

[MFC] 리스트 컨트롤 폰트 바꾸기

MFC나 API로 다이얼로그를 만들어서 하다보면 폰트가 마음에 안들때가 많습니다.

리스트 컨트롤로 헥스뷰어를 만들다가 폰트가 너무 마음에 안들어서 폰트 바꾸는 방법을 찾아봤습니다.

아래의 함수를 이용하면 폰트를 바꿀 수 있습니다.

HFONT CreateFont(
  int nHeight,             // logical height of font
  int nWidth,              // logical average character width
  int nEscapement,         // angle of escapement
  int nOrientation,        // base-line orientation angle
  int fnWeight,            // font weight
  DWORD fdwItalic,         // italic attribute flag
  DWORD fdwUnderline,      // underline attribute flag
  DWORD fdwStrikeOut,      // strikeout attribute flag
  DWORD fdwCharSet,        // character set identifier
  DWORD fdwOutputPrecision,  // output precision
  DWORD fdwClipPrecision,  // clipping precision
  DWORD fdwQuality,        // output quality
  DWORD fdwPitchAndFamily,  // pitch and family
  LPCTSTR lpszFace         // pointer to typeface name string
);

실제 사용은 아래와 같이 하면 됩니다.

HFONT hNewFont;   
hNewFont=CreateFont( 12,0,0,0,0,0,0,0,HANGEUL_CHARSET,3,2,1,       
                               VARIABLE_PITCH | FF_MODERN,"돋음");
m_hList.SendMessage( WM_SETFONT, (WPARAM)hNewFont, (LPARAM)TRUE);

m_hList는 리스트 컨트롤의 객체입니다.
만약 다른 컨트롤의 폰트를 바꾸고 싶다면 객체부분만 바꿔주면 됩니다.