CString strout[4];//literal output STROUT[0] = "1. Use function CreatePointFont () to create italicized word"; strout[1] = "2. Use function CreateFontIndirect () to create Italic, underlined boldface "; strout[2] =" 3. Use the function CreateFont () to create a large font with strikethrough "; strout[3] =" 4. Create an ANSI-standard, equal-width font using an inventory Font object ";//Create two Font objects CFont * Oldfont, NewFont; LOGFONT MyFont = {30,10,0,0,0,1,1,0,ansi_charset,out_default_precis,clip_default_precis,default_quality,default_ PITCH, "Blackbody"};pD c->textout (0, 10, "several ways to create fonts:");//displays several different effects of fonts for (int i = 0;i < 4;i++) {switch (i) {case 0://using function CreatePointFont () Create font newfont.createpointfont (200, "Arial", NULL); Break;case 1://use function CreateFontIndirect () Create Font newfont.createfontindirect (&myfont); Break;case 2:newfont.createfont (0, 0, Fw_heavy, False, False, TRUE , Ansi_charset, Out_default_precis, clip_default_precis,default_quality, Default_pitch | Ff_dontcare, "large character"); break;case 3://Use Inventory Font object to create Font pdc->selectstockobject (ansi_fixed_font); break;default:break;} Oldfont = Pdc->selectobject (&newfont);pD c->textout (0, (i+1), strout[i]);pD C->selectobject (OlDFont); Newfont.deleteobject ();}
VC + + uses GDI to create font output