Solved

How to check ENTER was pressed in edit box?

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 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

19 Experts available now in Live!

Get 1:1 Help Now