Okay so I wont to output text onto my win32 program. I read somewhere that TextOut() is the function i need but it is not as good as DrawText(); Ive been trying to use DrawText() but i get stuck at the 4 parameter asking for a RECT. Any help ? im Using VS2010

void paintWindow(HWND hWnd) {
	HDC hdc = GetDC(hWnd);
    char szSize[100];
    char szTitle[] = "These are the dimensions of your client area:";

    SetTextColor(hdc, COLORREF RGB (20, 13, 20));

	LPRECT rect;
	GetClientRect(hWnd, rect);

    DrawText(hdc, (LPCWSTR) szTitle, -1, /*NEED HELP HERE*/, DT_WORDBREAK);
6 Years
Discussion Span
Last Post by caut_baia

The reference for the DrawText function says it's a pointer to a RECT structure,

The reference for the RECT structure says it's four LONG variables,

So you can make a RECT like this:

RECT drawingArea;
memset(&drawingArea, 0, sizeof(RECT));
drawingArea.top = 0;
drawingArea.left = 0;
drawingArea.right = 150;
drawingArea.bottom = 150;

then use a rectangle with the function like this:

DrawText( hdc, (LPCWSTR) szTitle, -1, &drawingArea, DT_WORDBREAK );

HEy thanks guys it works. but now i got annoying screen flickers. Whats up with that? Oh and if i do (LPCWSTR) i get chinese letters

Edited by becool007: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.