Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

XDarkChronoX

Text Functions for Win32 API

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

I was wondering if anyone knew a way to use some sort of function like cout in a Win32 Application. I know how to use TextOut, but then I would have to plot out pixel coordinates for the function everytime I want text to be outputed and this seems too cumbersome to me. So basically I want it to automatically print at the coordinates for Win32 Applications like cout did for Console Applications. Any ideas? Thx!

Share this post


Link to post
Share on other sites
Advertisement
You need to plot the text. There is no equivalent of cout. You can output to a file by redirecting if you wish.. but thats it. If you really want a console, then make one. I made a little console once that ran in a separate thread (wrapped very little, but you can do it more if you like). You could use string streams... treat the string stream as a buffer, then use a special member to output to the console (and clear the buffer). That way you can have cout type functionality. Thats the best idea IMO as if you want you can make it reusable. I use similar techniques to that to debug quite frequently.

Share this post


Link to post
Share on other sites
You could just write a function to simulate cout or printf. I''m just typing this right here, but you get the idea I''m sure.


void OutputText(char *szText, bool bClear = false)
{
static int iY;

if(bClear == true)
iY = 0;


// I don''t remember TextOut too well, add that stuff here
// Gotta get a HDC, then Build a Font, or something like that
// Use iY for your Y co-ordinate, like..
TextOut(szText, 0, iY);

// Increase To Next Line, For Next Printing.
iY += 12;

return;
}

Pretty simple and doesn''t really clear the screen, but I leave that up to you if you''re so inclined.

If you''re sick of just doing all the TextOut crap, encapsulate it. Thats what encapsulation is for =)

Share this post


Link to post
Share on other sites

  • 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!