Hello, I am currently programming a Win32 application and I need a "text field" or a "text box" that the user can type in a number to. I will need a few of these so a example would be great.
Printable View
Hello, I am currently programming a Win32 application and I need a "text field" or a "text box" that the user can type in a number to. I will need a few of these so a example would be great.
Try the windows programming section of the forum.
.. and moved!
Sorry for posting in the wrong section. I didn't see the Windows programming section..
Use the resource editor to create the Editbox OR use CreateWindowEx() to create one at run time. If you have a lot I suggest the resource editor.
Read the text with GetDlgItemInt() or GetDlgItemText() and atoi().
Check some recent threads for code.
put this code in the WM_CREATE part of your WndProc. the codeCode:HWND hEdit =CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT",
"Type Text Here",WS_CHILD|WS_VISIBLE|WS_HSCROLL|ES_AUTOHSCROLL,
0,0,100,20,hwnd,(HMENU)SOME_KIND_OF_ID,GetModuleHandle(NULL),
NULL);
above makes a TextBox at x0 and y0 with a width of 100 and a
height of 20. the SOME_KIND_OF_ID should be defined somewhere
in your program like this:
the WS_HSCROLL and ES_AUTOHSCROLL can be removed (they makeCode:#define SOME_KIND_OF_ID 50
an horizontal scroll bar). 'hwnd' is the window to put this
control on. if any questions, ask please.
Cheers, ComputerWarrior.