Jump to content
  • Advertisement
Sign in to follow this  
Daedulus

TextOut Issues in VC++ 6.0

This topic is 5025 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
Advertisement
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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!