outputting/inputting text in windows app.
Hi.
I have made a blackjack game as a console application in C++. Now, I would like to turn it into a Windows Application (using windows api --though I know how to use directx, that seems like overkill for this). However, I am having problems with text input and output, especially the output part, since I can no longer use cin or cout.
It was suggested to me that I create a text box and have the user submit to it. I have no idea how to do this (though I do remember having made buttons in the past). Basically, the user should be able to enter any number as their bet for the deal.
Is TextOut() the best function to use for rendering the text?
Thanks
Dan
Feel free to email me at NYYanks432@hotmail.com if you have any questions
You shoul probably find some tutorials on the internet for this, or pick up a book. I find the best way to do what your talking about is to make a list box. Then instead out cout, you can just add a line to the list box. And for cin, you can take text from a textbox. I just finsihed writing a server application that works in the same manner. It took me 20 minutes to do (Not including server code). Good luck!
There''s a few ways to handle text display. Textout does work, i thinik there''s also drawtext.
Go here for the docs and search for textout and other gdi routines:
http://search.microsoft.com/us/dev/?MSCOMTB=ICP_SEARCH%20MSDN
If you want a dialog for your game, you could just drag a button onto it (assuming you have msvc or some other visual ide). If you want to create your own controls and windows, CreateWindowEx with "button" or something like that as the window class parameter should work.
Freeware development:
http://www.ruinedsoft.com/
Go here for the docs and search for textout and other gdi routines:
http://search.microsoft.com/us/dev/?MSCOMTB=ICP_SEARCH%20MSDN
If you want a dialog for your game, you could just drag a button onto it (assuming you have msvc or some other visual ide). If you want to create your own controls and windows, CreateWindowEx with "button" or something like that as the window class parameter should work.
Freeware development:
http://www.ruinedsoft.com/
___________________________Freeware development:ruinedsoft.com
Take a look at the cardgame sample at catch22.uk.net. The author goes over how he acquired the card bitmaps that windows uses in freecell and solitaire to build his version of "shithead" (shed as he calls it). Get to know buttons and owner drawn buttons too. I don''t think it will take much more to build a card game - even a betting card game.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
Ok, textout is working pretty well now. However, I have another question.
How can I keep adding text to a buffer and then print out the entire thing at once?
For example:
The reason I would like to do this is so that I don''t need to worry about the fact that the number of the card may be a different length when I output what cards the user has.
Thanks for all your help so far.
How can I keep adding text to a buffer and then print out the entire thing at once?
For example:
if (card.number == 11) { //add jack to buffer}else if (card.number == 12 ){ // add queen to buffer } //etc.else if (card.number <=10) // add card.number to buffer}if ( card.suit == ''h'' ) //add hearts to bufferelse if (card.suit ==''c'') // add clubs to buffer//etc.//PRINT ENTIRE BUFFER HERE
The reason I would like to do this is so that I don''t need to worry about the fact that the number of the card may be a different length when I output what cards the user has.
Thanks for all your help so far.
Feel free to email me at NYYanks432@hotmail.com if you have any questions
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement