Solved

How to check ENTER was pressed in edit box?

Posted on 1998-02-03
2
360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

690 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