Sign in to follow this  

TextOut Issues in VC++ 6.0

This topic is 4719 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

After exclusively doing OpenGL programming, I've started to take a look at Win32 programming. I'm trying (and failing:P) to do something rediculously simple: print text to the screen. I've set it up into a function as follows: bool winPrint (WIN* win, char* text) { static TEXTMETRIC textInfo; static int length = 0; PAINTSTRUCT paintStruct; int x, y; GetTextMetrics (win->hDC, &textInfo); length = strlen (text); textInfo.tmCharSet = ANSI_CHARSET; win->hDC = BeginPaint (win->hWnd, &paintStruct); SetTextColor (win->hDC, RGB (255, 255, 255)); x = (win->winInit.width) / 2; x -= (length * textInfo.tmAveCharWidth) / 2; y = (win->winInit.height) / 2; y -= (textInfo.tmHeight) / 2; if (TextOut (win->hDC, x, y, text, length) == 0) { MessageBox (HWND_DESKTOP, "ERROR: TextOut failed.", "WINPRINT ERROR", MB_OK | MB_ICONEXCLAMATION); return false; } EndPaint (win->hWnd, &paintStruct); return true; } Where win is a pointer to a structure holding all my window data (window handle, device context, etc). I then call this function during my main loop while handling messages: if (PeekMessage (&msg, win.hWnd, 0, 0, PM_REMOVE) != 0) { if (msg.message != WM_QUIT) { if (msg.message == WM_PAINT) { winPrint (&win, "Jus any sort of text"); } else { DispatchMessage (&msg); } } ... Problem is, only an outline of the text field appears, no actual defined text. Any suggestions??

Share this post


Link to post
Share on other sites
Quote:
Original post by Daedulus
Nope, my background is black, my text white. Here's a pic ti make my problem a little clearer:

http://www.geocities.com/thagangsta711/prgm01.JPG

Nay! Mastaba's talking about the "text-background-color", set with SetTextBkColor. When you TextOut, the frame of the text is given the color of the text background color, and the text is printed on it with the foreground color.

Share this post


Link to post
Share on other sites

This topic is 4719 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this