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);
}

The reference for the DrawText function says it's a pointer to a RECT structure,
http://msdn.microsoft.com/en-us/library/dd162498%28v=vs.85%29.aspx

The reference for the RECT structure says it's four LONG variables,
http://msdn.microsoft.com/en-us/library/dd162897%28v=vs.85%29.aspx

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 5 Years Ago by becool007: n/a

This article has been dead for over six months. Start a new discussion instead.