Editbox question

Started by
3 comments, last by simon10k 18 years, 10 months ago
Im using the Win32 API, I've got an Editbox, a Listbox and a few buttons. The Editbox is a single lined editbox which when I click the Add button the text is put into the Listbox. I want to be able to press the return key to perform the same function as pressing the Add button would do. I've tried numerous things but nothing seems to work.
-----------------------------Language: C++API: Win32, DirectXCompiler: VC++ 2003
Advertisement
What are you doing this in (.NET, VB, Delphi, MFC etc)

normally you just add an OnKeyPress event handler and check if the Key is char(13). If it is add the textbox text to the listbox and normally clear the textbox ready for the next entry

Hope it helps

Mark

You can subclass the edit box and catch WM_KEYUP in your custom window proc and react upon enter there. Win32 is a pain though, I would suggest something easier like c# if you want to do GUI development.
Probably the simplest thing would be to give the add button the default button style. If a control doesn't accept enter the dialog acts as if the dialogs default button was pushed.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

I'm just using C++ and Win32, not visual development. I've just nailed it, sub classing the edit -thanks guys, and doho.

[Edited by - simon10k on June 12, 2005 10:56:31 AM]
-----------------------------Language: C++API: Win32, DirectXCompiler: VC++ 2003

This topic is closed to new replies.

Advertisement