나는 쉽게 글꼴 크기를 변경할 수 있기를 원하는 CListCtrl 클래스가 있습니다. MyListControl로 CListCtrl을 서브 클래 싱했습니다. PreSubclassWindow 이벤트 처리기에서이 코드를 사용하여 글꼴을 성공적으로 설정할 수 있습니다.MFC : 동적으로 제어 글꼴 크기를 변경합니까?
void MyListControl::PreSubclassWindow()
{
CListCtrl::PreSubclassWindow();
// from http://support.microsoft.com/kb/85518
LOGFONT lf; // Used to create the CFont.
memset(&lf, 0, sizeof(LOGFONT)); // Clear out structure.
lf.lfHeight = 20; // Request a 20-pixel-high font
strcpy(lf.lfFaceName, "Arial"); // with face name "Arial".
font_.CreateFontIndirect(&lf); // Create the font.
// Use the font to paint a control.
SetFont(&font_);
}
이것은 작동합니다. 그러나, 내가하고 싶은 것은 SetFontSize (int 크기)라는 메서드를 만드는 것입니다.이 메서드는 기존 글꼴 크기를 그대로 변경합니다 (얼굴과 다른 특성을 그대로 남겨 둡니다). 그래서 나는 (이 내 프로그램을 죽이는)이 방법은 기존의 글꼴을 가져온 다음 글꼴 크기 그러나 이것은 실패 할 내 시도를 변경해야 믿습니다
void MyListControl::SetFontSize(int pixelHeight)
{
LOGFONT lf; // Used to create the CFont.
CFont *currentFont = GetFont();
currentFont->GetLogFont(&lf);
LOGFONT lfNew = lf;
lfNew.lfHeight = pixelHeight; // Request a 20-pixel-high font
font_.CreateFontIndirect(&lf); // Create the font.
// Use the font to paint a control.
SetFont(&font_);
}
나는이 방법을 만드는 방법을
?
이 방법으로 프로그램을 "종료"합니까? – Jollymorphic
실패한 mfc ASSERT가 있습니다. – User