Skip to main content
gamedev.net
🔒 Locked

Message Box

Started by SCarvenger 8 replies 950+ views
Original Post
SCarvenger
SCarvenger
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.
Evil Steve
Evil Steve
What version of DirectX? ID3DXFont is usually a good way of handling this, and using standard window messages for the input (WM_CHAR).
circlesoft
circlesoft
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).
SCarvenger
SCarvenger
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
Evil Steve
Evil Steve
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]
SCarvenger
SCarvenger
ok, now we making some progress, instead of showing null, it shows anything. :(
Jack Sotac
Jack Sotac
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
0xa0000000
SCarvenger
SCarvenger
ah sure! sorry! thank you!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.