Skip to main content
gamedev.net
🔒 Locked

Edit Box

Started by Squeee Aug 4, 2003 at 12:48 PM 3 replies 300+ views
Original Post
Squeee
Squeee
So I am writing a program in VC++. I have this dialog box wich has an edit box and two buttons(ok and cancel). When the user clicks ok I want to store whatever the user has typed in the edit box into a string. I can not figure out how to get what has been typed in the edit box. I know that GetWindowText( string ); will get the name of the window and store it in the string. Is there another function I cant think of to get what is in the message box?
Taco?
Colin Jeanne
Colin Jeanne
GetWindowText() will get the text from an edit but I think a better function for you would be GetDlgItemText().



Qui fut tout, et qui ne fut rien
Invader''s Realm
BlueDev
BlueDev
Hello,

I wrote a few tutorials on Edit Boxes on my site, BlueDev, so please feel free to view them under the Win32 section.

Need anymore information please email me at bluedev@bluedev.net

- BlueDev
[/quote]
Yanroy
Yanroy
If you''re using the classwizard (which it sounds like you''re not...), then you need to associate a member variable with your edit box by ctrl+doubleclicking on the edit box in the resource editor. Then it should automatically do the behaviour you''re describing. And you can call UpdateData() to refresh it if you want to use the data someplace else before the dialog closes. That''s if you''re using MFC.

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming

You are unique. Just like everybody else.

"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor
Xgkkp
Xgkkp
Under the Dialog box Procedure, look for a case of WM_COMMAND for msg and ID_OK for the loword(wParam). In that code, use:

UINT GetDlgItemText(
HWND hDlg, // handle of dialog box
int nIDDlgItem, // identifier of control
LPTSTR lpString, // address of buffer for text
int nMaxCount // maximum size of string
);

To get the text

Topic Locked

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

Sign in to reply to this topic.