2.2 Output text in the window
Here I assume that the reader has generated a program code for an SDI interface with ApplicationWizard. Next you only need to join the drawing code in the CVIEW derived Ondraw member function. Here I need to explain the role of the onDraw function, the onDraw function is automatically called when the window needs to be redrawged, and the incoming parameter CDC * PDC corresponds to the DC environment. The advantage of using OnDRAW is that the DC environment that is incoming to the OnDraw when you use the print function, it will be a printer drawing environment. When you use a print preview, it is incoming a drawing environment called CPREVIEWDC, so you only need a code. You can complete window / print preview / printer drawing triple function. Using Windows Devices Non-related and M $ to print preview, you can easily complete a software with what you get. Output text generally uses CDC :: Bool Textout (int X, int y, const cstring & str), and CDC :: Int Drawtext (Const Cstring & Str, LPRect LPRect, Uint Nformat), only to output a single line for Textout Text, while DrawText can specify whether to output a single line or multi-line text in a rectangle, and can specify alignment and what style of use. NFORMAT can be a combination of a plurality of markers (use bits or operations) to achieve the purpose of selecting output styles.
Bottom DT_BOTTOM alignment Specifies bottom-justified text. This value must be combined with DT_SINGLELINE. The rectangular dimensions Determines the width and height required of the rectangle. If there are multiple lines of text, DrawText will use the width of the time DT_CALCRECT calculating the specified text rectangle pointed to by lpRect and extend the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText will modify the right side of the rectangle so that it bounds the last character in the line. in either case, DrawText returns the height of the formatted text, but does not draw the text. central DT_CENTER align Centers text horizontally. DT_END_ELLIPSIS or DT_PATH_ELLIPSIS Replaces part of the given string with ellipses, if necessary, so that the result fits in the specified rectangle . The given string is not modified unless the DT_MODIFYSTRING flag is specified. You can specify DT_END_ELLIPSIS to replace characters at the end of the string, or DT_PATH_ELLIPSIS to replace characters in the middle of the st ring. If the string contains backslash (/) characters, DT_PATH_ELLIPSIS preserves as much as possible of the text after the last backslash. DT_EXPANDTABS Expands tab characters. The default number of characters per tab is eight. DT_EXTERNALLEADING Includes the font Zha external leading in the line height. Normally, external leading is not included in the height of a line of text. DT_LEFT left Aligns text flush-left. DT_MODIFYSTRING Modifies the given string to match the displayed text. This flag has no effect unless the DT_END_ELLIPSIS or DT_PATH_ELLIPSIS flag IS specified. Note Some uformat flag combinations can cause the passed string to be modified.
Using DT_MODIFYSTRING with either DT_END_ELLIPSIS or DT_PATH_ELLIPSIS may cause the string to be modified, causing an assertion in the CString override. DT_NOCLIP Draws without clipping. DrawText is somewhat faster when DT_NOCLIP is used. DT_NOPREFIX prohibit the use & prefix Turns off processing of prefix characters. Normally , DrawText interprets the ampersand (&) mnemonic-prefix character as a directive to underscore the character that follows, and the two-ampersand (&&) mnemonic-prefix characters as a directive to print a single ampersand. By specifying DT_NOPREFIX, this processing is turned off. DT_PATH_ELLIPSIS DT_RIGHT right justified Aligns text flush-right. DT_SINGLELINE single line output Specifies single line only. Carriage returns and linefeeds do not break the line. DT_TABSTOP TAB character set width occupied Sets tab stops. The high-order byte of nFormat is The Number of Characters for Each Tab. The Default Number of Characters Per Tab Is Eight. DT_TOP Division Align Specifies Top-Justified Text (Single Line Only). DT_VCenter Aligned SPE cifies vertically centered text (single line only). DT_WORDBREAK per line is wrapped Specifies word-breaking between words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by lpRect. A carriage return Zhe INEFEED SEQUENCE WILL ALSO BREAK THE LINE. If you want to change the color of the text when you output text, you can use CDC :: SetTextColor (ColorRef CRColor), if you want to change the background color, use CDC :: SetBkcolor, Many times you might need a transparent background color you can use CDC :: SetBkmode (int NBKMODE) setting, acceptable parameters
OPAQUE Background is filled with the current background color before the text, hatched brush, or pen is drawn. This is the default background mode. TRANSPARENT Background is not changed before drawing. Then talk about how to create a font, you can create are Both: Stock Fonts CDC :: CreateStockObject (int NINDEX) and custom fonts. You need to populate a logfont structure when you create a non-stock font and use cfont :: createFontIndirect (Const Logfont * LPLogfont) (you can refer to the article to display GB characters and BIG5 characters in the same system), or use cfont :: CreateFont (int NHEIGHT, INT) nWidth, int nEscapement, int nOrientation, int nWeight, BYTE bItalic, BYTE bUnderline, BYTE cStrikeOut, BYTE nCharSet, BYTE nOutPrecision, BYTE nClipPrecision, BYTE nQuality, BYTE nPitchAndFamily, LPCTSTR lpszFacename) parameters and LOGFONT wherein the component to be correspond relationship. The meaning of the parameters is explained below: NHEIGHT font height (logical unit) is equal to zero to default height, otherwise absolute value and can match the font height. NWIDTH width (logical unit) If zero is used to match the available horizontal bow. The angle between the baseline of the font angle between the X axis and the X-axis vector nEscapement outlet nOrientation nWeight font weight, preferably the following values are ConstantValueFW_DONTCARE0FW_THIN100FW_EXTRALIGHT200FW_ULTRALIGHT200FW_LIGHT300FW_NORMAL400FW_REGULAR400FW_MEDIUM500FW_SEMIBOLD600FW_DEMIBOLD600FW_BOLD700FW_EXTRABOLD800FW_ULTRABOLD800FW_BLACK900FW_HEAVY900bItalic whether italic underlined cStrikeOut bUnderline strikethrough nCharSet whether the specified set of characters, which can take the values
ConstantValueansi_Charset0Default_Charset1Symbol_charset2shiftjis_charset128oem_charset255noutPrecision output accuracy
OUT_CHARACTER_PRECISOUT_STRING_PRECISOUT_DEFAULT_PRECISOUT_STROKE_PRECISOUT_DEVICE_PRECISOUT_TT_PRECISOUT_RASTER_PRECISNCLIPPRECISION clip accuracy, you can get the following value
CLIP_CHARACTER_PRECISCLIP_MASKCLIP_DEFAULT_PRECISCLIP_STROKE_PRECISCLIP_ENCAPSULATECLIP_TT_ALWAYSCLIP_LH_AGLESNQUALITY OR output quality, the following value