Jump to content
  • Advertisement
Sign in to follow this  
SCarvenger

Message Box

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

Im doing an online RPG and i would like to do a message box that recognizes the letters that the player types like if the player types "A" it appears "A" in the box like a chat in-game. I know how to do that with Windows, but outside the game, not in the game. Im very noob at Directx sorry for my question.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Evil Steve
using standard window messages for the input (WM_CHAR).

Yea, WM_CHAR rocks for things like this. Here is an article explaining why (and how to use it).

Share this post


Link to post
Share on other sites
this is not working :/

long FAR PASCAL AppWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
cApplication App;
switch(uMsg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_CHAR:
App.KeyText += (char)wParam; //string KeyText
break;

default: return g_pApplication->MsgProc(hWnd, uMsg, wParam, lParam);
}
}

But when i render it to the display it says that App.Keytext is null.
KeyText is public

cApplication::RenderScene() {
...
sprintf(Stats, "Text %s", KeyText);
m_Stats.Render(Stats);
...
}

Thank you for your help

Share this post


Link to post
Share on other sites
If KeyText is a std::string, then you should use sprintf(Stats, "Text %s", KeyText.c_str());
Actually, if you're using std::string, you should avoid sprintf completely, and use std::stringstream.

Note: I'm a hypocrite - I use sprintf() all the time [smile]

Share this post


Link to post
Share on other sites
Shouldn't it be:
g_pApplication->KeyText+=(char)wParam;

Otherwise the local variable string App.KeyText will keep resetting itself each time the function is entered.

Good Luck

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!