Jump to content
  • Advertisement
Sign in to follow this  
kyuss

TextOut problem Help. win32.

This topic is 4994 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

Does anyone know how to use TextOut to display an int in the client area. Do i have to convert an int to a TCHAR? if so how? BOOL TextOut( HDC hdc, // handle to DC int nXStart, // x-coordinate of starting position int nYStart, // y-coordinate of starting position LPCTSTR lpString, // character string int cbString // number of characters ); thats the function all I want to do is Display the following text: "10 Green Bottles Sitting on the Wall If the wind began to blow There would be 9 Green bottles sitting on the wall" you press a key, and the count goes down by 1, until there are no bottles. I'm just learning, so only reply if you can help. Help is very much appreciated.

Share this post


Link to post
Share on other sites
Advertisement
You need to convert the int into a string or char array.

Easiest:

char szTemp[260];

wsprintf( szTemp, "%d bottles of wheat beverage on the wall, %d to go", iBottles, iBottlesToGo );

The %d will be replaced by an int.


Alternatively you can use std::string and stringstream.

std::stringstream strStream;

strStream << iBottles << " bottles of wheat beverage on the wall, " << iBottlesToGo << " to go";

To get the result as const char* you call strStream.str().c_str();

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
excellent, thanks mate

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!