HDC hDC; LOGFONT LF; COLORREF lastcr; HFONT hFont, oFont;
// Font Initialization memset(&LF, 0, sizeof(LF)); LF.lfHeight = -10; LF.lfWidth = 0; LF.lfEscapement = 0; LF.lfOrientation = 0; LF.lfWeight = FW_NORMAL; LF.lfItalic = 0; LF.lfUnderline = 0; LF.lfStrikeOut = 0; LF.lfCharSet = ANSI_CHARSET; LF.lfOutPrecision = OUT_DEFAULT_PRECIS; LF.lfClipPrecision = CLIP_DEFAULT_PRECIS; LF.lfQuality = PROOF_QUALITY; LF.lfPitchAndFamily = VARIABLE_PITCH | FF_ROMAN; strcpy(LF.lfFaceName, "Times New Roman"); hFont = CreateFontIndirect(&LF);
// Use it like this: hDC = GetDC(hWnd); oFont = (HFONT)SelectObject(hDC, hFont); lastcr = SetTextColor(hDC, RGB(0x80, 0x40, 0x20)); TextOut(hDC, 0, 0, "Fonts!!", 7); SetTextColor(hDC, lastcr); SelectObject(hDC, oFont); ReleaseDC(hWnd, hDC);
// Kill Font DeleteObject(hFont); |