Solved

How to check ENTER was pressed in edit box?

Posted on 1998-02-03
2
335 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now