Jump to content
  • Advertisement


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


Getting User Input in Windows

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

In a dos program I would just use: cout<< Whats your name?; cin>> Name How do I put this in the main event loop in a win32 program? Im using Visual C++ 6 I can print what is your name using sprintf and TextOut but I cant get it to let me type anything in Please help Thanx "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face

Share this post

Link to post
Share on other sites
Windows has no standard input stream (or output stream, hence the required use of GDI''s TextOut). To get input you have a few options..
1. have your WindowProc function implement a WM_KEYDOWN message handler
2. create a giant edit control and have it fill your entire window (this is basically how notepad works)
3. open a dialog box with input controls in it

It all depends on what kind of input you want. If you want to prompt the user to give you data, then the third way is best. If you''re trying to emulate notepad, then go with the second way. And if you''re in a game and trying to get keyboard messages, use the first way.

-RWarden (robete@maui.net)

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!