CreateWindow() and EDIT - How to read text field?

  • Thread starter Thread starter JigglyBit
  • Start date Start date
J

JigglyBit

Guest
I am trying to create an editable text field in an application. Digging through documentation on parameters I am a little overwhelmed. Typical novice type question from me, how do I create an edit box and read the value as the user enters information?

I am playing around with this right now.

HWND hwText1 = CreateWindow(L"EDIT", //pre-defined class type in unicode definition
L"10", ES_NUMBER | WS_VISIBLE | WS_CHILD | WS_BORDER | ES_CENTER, //button attributes
680, //x position relative to parent frame
200, //y position relative to parent frame
50, //width
20, //height
hWnd, //handle to parent window
HMENU(1104), //window doesn't contain a menu
(HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),
nullptr); //generic ponter value can be passed but is not needed

//SendMessage(hwText1, WM_SETTEXT, 0, (LPARAM) "L23");




I am making the assumption that SendMessage() and GetMessage() are the correct mechanisms to accomplish this, probably incorrectly. When I execute this with the SendMessage() uncommented after creation for testing, I don't see what I expect, which would be a default text value populated in the window perhaps overwriting the initial declaration value of "L10." I do see a string of garble that I had declared to display in a message box from a definition after this though. So I am coming to the conclusion that I do not understand the function of WPARAM or LPARAM here. Can someone give me a straightforward example of how to declare and EDIT box, properly populate initial value, and read when a user changes that value? Automatically would be a plus (ideally when a '\n' is entered after numerical value). Right now I can select the field, modify it, but issuing a '\n' is disregarded with a ding. And I don't know the proper methodology to extract the value.


Graphics post update.

Continue reading...
 
Back
Top