Solved

How to check ENTER was pressed in edit box?

Posted on 1998-02-03
2
347 Views
Last Modified: 2013-12-03
How to determine when user press ENTER "in" single line edit box ?:

control = CreateWindow( "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
        5, 5, 495, 200, hwnd, (HMENU)ID_OUTBOX, hInst, NULL );

This:
   case WM_KEYDOWN:
         nVirtKey = (int) wParam;    
         if( nVirtKey == VK_RETURN && control == GetFocus() )

doesn't work.

This:
   case WM_COMMAND:
         wNotifyCode = HIWORD(wParam);
         wID = LOWORD(wParam);
         if( wID==ID_OUTBOX && wNotifyCode==EN_CHANGE )

is not what I want, I want ONLY ENTER, something like "WM_NEWLINE" or
"EN_CARRIAGERETURN".

                  Please help,
                              Robert
0
Comment
Question by:beton
2 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 1410853
Normally the RETURN is "wired" into the default button on the parent form (i.e. the OK button). If you want to receive the RETURN button in your EDIT control, create it with the ES_WANTRETURN flag in the resource file or click the "Want return" in the VC++ DevStudio dialog editor.
0
 

Author Comment

by:beton
ID: 1410854
This style has no effect on a single-line edit control.
And I'm not interesting in MFC solution, in fact I found
way out, I use NewProcEdit function as control message quelle
handler and do "case WM_KEYDOWN : if (wParam == VK_RETURN)"
OldProcEdit = (WNDPROC) SetWindowLong (chatin, GWL_WNDPROC,
                  (LONG) NewProcEdit);
ant it works great !
But thx very much :) ES_WANTRETURN is that I didn't know.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
error email attachment VB2010 5 46
Asp.net Form view Pager Template First Record 2 82
Trouble with References... 5 59
Windows ICD FFU Issue 4 59
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question