c++ - Edit control can't set text to empty string -
i have edit control:
hwnd hinput = createwindowex(ws_ex_clientedge, "edit", "", ws_child | ws_visible | ws_vscroll | es_multiline | es_autovscroll | es_wantreturn, 0, 0, 100, 100, hwnd, (hmenu)idc_main_input, getmodulehandle(null), null); and when button pressed i'm getting text , try replace empty string:
tchar buff[2048]; memset(buff,0,2048); getwindowtext(hinput, buff, 2048); setwindowtext(hinput,""); but after in edit control there new line left.
any ideas how remove new line? in advance.
edit: button pressed it's ok, no new lines.
the edit control has message procedure captures enter key , same thing button when it's pressed. here procedure:
lresult callback subclassproc(hwnd hwnd, uint msg, wparam wparam, lparam lparam) { switch (msg) { case wm_keydown: switch (wparam) { case vk_return: tchar buff[2048]; memset(buff,0,2048); getwindowtext(hinput, buff, 2048); setwindowtext(hinput,""); break; } break; } return callwindowproc(defproc, hwnd, msg, wparam, lparam); } but here leaves new line.
when process wm_keydown, clear edit control.
then pass message on base class, edit control, , inserts carriage return text. that's 1 theory. if it's correct, not sending wm_keydown message on base class solve problem.
another theory wm_keydown followed wm_char (synthesized translatemessage), , edit control added carriage return based on message. if it's correct, have interesting situation you've said wanted multiline edit control, you're trying clear content every time user tries create new line.
i misspoke es_wantreturn. works dialog box code make sure doesn't steal carriage return keypresses altogether. that's why changed original answer.
Comments
Post a Comment