outtextxy

The function is used to output the string at the specified location.

void outtextxy(
	int x,
	int y,
	LPCTSTR str
);
void outtextxy(
	int x,
	int y,
	TCHAR c
);

Parameters

x

The coordinate value of the x-axis of the first letter when the string outputs.

y

The coordinate value of the y-axis of the first letter when the string outputs.

str

The pointer to the string to be output.

c

The character to be output.

Return Value

None

Remarks

The function does not change the current position.

Strings are commonly encoded in two ways: MBCS and Unicode. VC6 New projects default to MBCS encoding, and VC2008 and higher versions of VC default to Unicode encoding. LPCTSTR can be adapted to both encodings at the same time. To accommodate both encodings, use the TCHAR string and related functions.

By default, the background of the output string is filled with the current background color. Use the function setbkmode to set the background portion of the text to remain transparent or to fill with a background color.

Examples

// Output string (Multi-Byte character set)
char s[] = "Hello World";
outtextxy(10, 20, s);
// Output string (Unicode character set)
wchar_t s[] = L"Hello World";
outtextxy(10, 20, s);
// Output string (Project character set)
TCHAR s[] = _T("Hello World");
outtextxy(10, 20, s);
// Output characters (Multi-Byte character set)
char c = 'A';
outtextxy(10, 40, c);
// Output characters (Project character set)
TCHAR c = _T('A');
outtextxy(10, 40, c);
// Output value, first format the number output as a string (Multi-Byte character set)
char s[5];
sprintf(s, "%d", 1024);
outtextxy(10, 60, s);
// Output value 1024, first format the number output as a string (Project character set)
TCHAR s[5];
_stprintf(s, _T("%d"), 1024);        // High-version VC recommend the use of the _stprintf_s function
outtextxy(10, 60, s);