티스토리 뷰
TextOut
The TextOut function writes a character string at the specified location, using the currently selected font, background color, and text color.
BOOL TextOut(
HDC hdc, // handle to device context
int nXStart, // x-coordinate of starting position
int nYStart, // y-coordinate of starting position
LPCTSTR lpString, // pointer to string
int cbString // number of characters in string
);
Parameters
- hdc
- Handle to the device context.
- nXStart
- Specifies the logical x-coordinate of the reference point that the system uses to align the string.
- nYStart
- Specifies the logical y-coordinate of the reference point that the system uses to align the string.
- lpString
- Pointer to the string to be drawn. The string does not need to be zero-terminated, since cbString specifies the length of the string.
- cbString
- Specifies the number of characters in the string.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Windows NT: To get extended error information, call GetLastError.
Remarks
The interpretation of the reference point depends on the current text-alignment mode. An application can retrieve this mode by calling the GetTextAlign function; an application can alter this mode by calling the SetTextAlign function.
By default, the current position is not used or updated by this function. However, an application can call the SetTextAlign function with the fMode parameter set to TA_UPDATECP to permit the system to use and update the current position each time the application calls TextOut for a specified device context. When this flag is set, the system ignores the nXStart and nYStart parameters on subsequent TextOut calls.
When the TextOut function is placed inside a path bracket, the system generates a path for the TrueType text that includes each character plus its character box. The region generated is the character box minus the text, rather than the text itself. You can obtain the region enclosed by the outline of the TrueType text by setting the background mode to transparent before placing the TextOut function in the path bracket. Following is sample code that demonstrates this procedure.
// Obtain the window's client rectangle
GetClientRect(hwnd, &r);
// THE FIX: by setting the background mode
// to transparent, the region is the text itself
// SetBkMode(hdc, TRANSPARENT);
// Bracket begin a path
BeginPath(hdc);
// Send some text out into the world
TextOut(hdc, r.left, r.top, "Defenestration can be hazardous", 4);
// Bracket end a path
EndPath(hdc);
// Derive a region from that path
SelectClipPath(hdc, RGN_AND);
// This generates the same result as SelectClipPath()
// SelectClipRgn(hdc, PathToRegion(hdc));
// Fill the region with grayness
FillRect(hdc, &r, GetStockObject(GRAY_BRUSH));
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows:
Requires Windows 95 or later.
Windows CE:
Unsupported.
Header: Declared in wingdi.h.
Import
Library: Use gdi32.lib.
Unicode: implemented as Unicode and ANSI
versions on Windows and Windows NT.
See Also
Fonts and Text Overview, Font and Text Functions, GetTextAlign, SelectObject, SetBkColor, SetTextAlign, SetTextColor, TabbedTextOut
DrawText
The DrawText function draws formatted text in the specified rectangle. It formats the text according to the specified method (expanding tabs, justifying characters, breaking lines, and so forth).
int DrawText(
HDC hDC, // handle to device context
LPCTSTR lpString, // pointer to string to draw
int nCount, // string length, in characters
LPRECT lpRect, // pointer to struct with formatting dimensions
UINT uFormat // text-drawing flags
);
Parameters
- hDC
- Handle to the device context.
- lpString
- Pointer to the string to be drawn. If the nCount parameter is –1, the
string must be null-terminated.
If uFormat includes DT_MODIFYSTRING, the function could add up to four additional characters to this string. The buffer containing the string should be large enough to accommodate these extra characters.
- nCount
- Specifies the number of characters in the string. If nCount is –1, then the lpString parameter is assumed to be a pointer to a null-terminated string and DrawText computes the character count automatically.
- lpRect
- Pointer to a RECT structure that contains the rectangle (in logical coordinates) in which the text is to be formatted.
- uFormat
- Specifies the method of formatting the text. It can be any combination of
the following values:
Value Description DT_BOTTOM Justifies the text to the bottom of the rectangle. This value must be combined with DT_SINGLELINE. DT_CALCRECT Determines the width and height of the rectangle. If there are multiple lines of text, DrawText uses the width of the rectangle pointed to by the lpRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText modifies 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. DT_CENTER Centers text horizontally in the rectangle. DT_EDITCONTROL Duplicates the text-displaying characteristics of a multiline edit control. Specifically, the average character width is calculated in the same manner as for an edit control, and the function does not display a partially visible last line. 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 string. 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 external leading in line height. Normally, external leading is not included in the height of a line of text. DT_INTERNAL Uses the system font to calculate text metrics. DT_LEFT Aligns text to the 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. DT_NOCLIP Draws without clipping. DrawText is somewhat faster when DT_NOCLIP is used. DT_NOPREFIX Turns off processing of prefix characters. Normally, DrawText interprets the mnemonic-prefix character & as a directive to underscore the character that follows, and the mnemonic-prefix characters && as a directive to print a single &. By specifying DT_NOPREFIX, this processing is turned off. DT_RIGHT Aligns text to the right. DT_RTLREADING Layout in right to left reading order for bi-directional text when the font selected into the hdc is a Hebrew or Arabic font. The default reading order for all text is left to right. DT_SINGLELINE Displays text on a single line only. Carriage returns and linefeeds do not break the line. DT_TABSTOP Sets tab stops. Bits 15–8 (high-order byte of the low-order word) of the uFormat parameter specify the number of characters for each tab. The default number of characters per tab is eight. DT_TOP Top-justifies text (single line only). DT_VCENTER Centers text vertically (single line only). DT_WORDBREAK Breaks words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the lpRect parameter. A carriage return-linefeed sequence also breaks the line. DT_WORD_ELLIPSIS Truncates text that does not fit in the rectangle and adds ellipses.
Note The DT_CALCRECT, DT_EXTERNALLEADING, DT_INTERNAL, DT_NOCLIP, and DT_NOPREFIX values cannot be used with the DT_TABSTOP value.
Return Values
If the function succeeds, the return value is the height of the text.
If the function fails, the return value is zero.
Windows NT: To get extended error information, call GetLastError.
Remarks
The DrawText function uses the device context's selected font, text color, and background color to draw the text. Unless the DT_NOCLIP format is used, DrawText clips the text so that it does not appear outside the specified rectangle. All formatting is assumed to have multiple lines unless the DT_SINGLELINE format is specified.
If the selected font is too large for the specified rectangle, the DrawText function does not attempt to substitute a smaller font.
Windows CE: If DT_CALCRECT is specified for the uFormat parameter, you must set the right and bottom members of the RECT structure pointed to by lpRect.
Windows CE does not support the DT_EXTERNALLEADING flag for the uFormat parameter.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows:
Requires Windows 95 or later.
Windows CE: Requires version 1.0
or later.
Header: Declared in winuser.h.
Import Library:
Use user32.lib.
Unicode: Implemented as Unicode and ANSI
versions on Windows NT.
See Also
Fonts and Text Overview, Font and Text Functions, GrayString, TabbedTextOut, TextOut, RECT
SetTextColor
The SetTextColor function sets the text color for the specified device context to the specified color.
COLORREF SetTextColor(
HDC hdc, // handle to device context
COLORREF crColor // text color
);
Parameters
- hdc
- Handle to the device context.
- crColor
- Specifies the color of the text.
Return Values
If the function succeeds, the return value is a color reference for the previous text color.
If the function fails, the return value is CLR_INVALID.
Windows NT: To get extended error information, call GetLastError.
Remarks
The text color is used to draw the face of each character written by the TextOut and ExtTextOut functions. The text color is also used in converting bitmaps from color to monochrome and vice versa.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows:
Requires Windows 95 or later.
Windows CE: Requires version 1.0
or later.
Header: Declared in wingdi.h.
Import Library:
Use gdi32.lib.
See Also
Fonts and Text Overview, Font and Text Functions, BitBlt, ExtTextOut, GetTextColor, RGB, SetBkColor, StretchBlt, TextOut
SetBkColor
The SetBkColor function sets the current background color to the specified color value, or to the nearest physical color if the device cannot represent the specified color value.
COLORREF SetBkColor(
HDC hdc, // handle of device context
COLORREF crColor // background color value
);
Parameters
- hdc
- Handle to the device context.
- crColor
- Specifies the new background color.
Return Values
If the function succeeds, the return value specifies the previous background color as a COLORREF value.
If the function fails, the return value is CLR_INVALID.
Windows NT: To get extended error information, call GetLastError.
Remarks
This function fills the gaps between styled lines drawn using a pen created by the CreatePen function; it does not fill the gaps between styled lines drawn using a pen created by the ExtCreatePen function. The SetBKColor function also sets the background colors for TextOut and ExtTextOut.
If the background mode is OPAQUE, the background color is used to fill gaps between styled lines, gaps between hatched lines in brushes, and character cells. The background color is also used when converting bitmaps from color to monochrome and vice versa.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows:
Requires Windows 95 or later.
Windows CE: Requires version 1.0
or later.
Header: Declared in wingdi.h.
Import Library:
Use gdi32.lib.
See Also
Painting and Drawing Overview, Painting and Drawing Functions, COLORREF, CreatePen, ExtCreatePen, GetBKColor, GetBkMode, SetBkMode
SetTextAlign
The SetTextAlign function sets the text-alignment flags for the specified device context.
UINT SetTextAlign(
HDC hdc, // handle to device context
UINT fMode // text-alignment flag
);
Parameters
- hdc
- Handle to the device context.
- fMode
- Specifies the text alignment by using a mask of the values in the following
list. Only one flag can be chosen from those that affect horizontal and vertical
alignment. In addition, only one of the two flags that alter the current
position can be chosen.
Value Meaning TA_BASELINE The reference point will be on the base line of the text. TA_BOTTOM The reference point will be on the bottom edge of the bounding rectangle. TA_TOP The reference point will be on the top edge of the bounding rectangle. TA_CENTER The reference point will be aligned horizontally with the center of the bounding rectangle. TA_LEFT The reference point will be on the left edge of the bounding rectangle. TA_RIGHT The reference point will be on the right edge of the bounding rectangle. TA_NOUPDATECP The current position is not updated after each text output call. The reference point is passed to the text output function. TA_RTLREADING Middle-Eastern Windows: The text is laid out in right to left reading order, as opposed to the default left to right order. This applies only when the font selected into the device context is either Hebrew or Arabic. TA_UPDATECP The current position is updated after each text output call. The current position is used as the reference point.
When the current font has a vertical default base line, as with Kanji, the following values must be used instead of TA_BASELINE and TA_CENTER:
Value Meaning VTA_BASELINE The reference point will be on the base line of the text. VTA_CENTER The reference point will be aligned vertically with the center of the bounding rectangle.
The default values are TA_LEFT, TA_TOP, and TA_NOUPDATECP.
Return Values
If the function succeeds, the return value is the previous text-alignment setting.
If the function fails, the return value is GDI_ERROR.
Windows NT: To get extended error information, call GetLastError.
Remarks
The TextOut and ExtTextOut functions use the text-alignment flags to position a string of text on a display or other device. The flags specify the relationship between a reference point and a rectangle that bounds the text. The reference point is either the current position or a point passed to a text output function.
The rectangle that bounds the text is formed by the character cells in the text string.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows:
Requires Windows 95 or later.
Windows CE:
Unsupported.
Header: Declared in wingdi.h.
Import
Library: Use gdi32.lib.
See Also
Fonts and Text Overview, Font and Text Functions, ExtTextOut, GetTextAlign, TextOut
- Total
- Today
- Yesterday
- 스프링 시큐리티(spring security)-http basic 인증
- java 키워드 정리
- error-java
- 람다식(lambda expression)
- java.sql
- 인텔리제이(intellij)
- MainActor
- 특정 문자를 기준으로 자르기
- 문자 자르기
- 메이븐(maven)
- 제품 등록
- React
- java-개발 환경 설정하기
- In App Purchase
- jstl(java standard tag library)-core
- 스프링 시큐리티(spring security)
- docker
- REST API
- system.io
- 스프링 프레임워크(spring framewordk)
- 진수 변환
- jstl(java standard tag library)
- nl2br
- 스프링 프레임워크(spring framework)
- System.Diagnostics
- jsp 오픈 소스
- 표현 언어(expression language)
- java web-mvc
- .submit()
- await
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |