Sign in to follow this  
SCarvenger

Message Box

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this