Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When I use kill focus for the edit then I must press tab button, how can I do if I want kill focus with key enter?

What I have tried:

I tried changing some properties of edit like tabstop and want return
Posted
Updated 27-Jul-21 11:20am

1 solution

You should subclass the edit control so that you can handle its key press events (such as WM_KEYDOWN or WM_KEYUP).

To create a subclass of a window, the system call SetWindowLongPtr() is called. The window handle is passed to this together with the GWLP_WNDPROC flag and the pointer to your user-defined window procedure.

Your custom window procedure effectively replaces or extends the standard window procedure for that control class.

In your own window procedure you can then react to a WM_KEYDOWN and check whether wParam == VK_RETURN.

Here you can replace the message or create a new one that corresponds to the desired reaction. The KillFocus message ist generated by the System wenn you call SetFocus() here and select another Window.
 
Share this answer
 
v2
Comments
Member 14594285 28-Jul-21 6:31am    
yes I know, but I need killFocus, I tried with your method but it isn't suited, I need kilLFous with key enter, thanks
merano99 28-Jul-21 16:58pm    
Edit controls are designed to either interpret Enter key presses as a new line (in a multiline edit control) or to ignore it. The way would be to subclass the edit control and call SetFocus () there. This then triggers the desired KillFocus message.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900