Processing Enter and Esc in CEdit
I am using a CEdit control as a child in a CListCtrl for purpose of making each column editable. The application is a dialog based app. My problem is... I have overwritten OnOK and OnCancel in the main dialog so the edit control never receives notifications for Escape or Enter whether in OnChar or PreTranslateMessage and I would like to delete the CEdit control after updating the CListCtrl on Enter. What can I do? I have rewritten this code many many times over the past 4 days and nothing is working.
Re: Processing Enter and Esc in CEdit
Did you try to subclass CListCtrl and handle LVN_KEYDOWN message in it (in the class derived from CListCtrl)?
Re: Processing Enter and Esc in CEdit
Just tried it. When the edit control has the focus KeyDown messages go to the edit control and either way the keydown still does not receive the enter and escape notification. the message I believe is being killed after the main Dialog receives it. I tried instead of OnOK and OnCancel to process the message in the main dialogs PreTranslateMessage Que and then pass the message on but the PreTranslateMessage won't process the ESCAPE and ENTER and dialog closes anyway.I am really stuck here.
Re: Processing Enter and Esc in CEdit
Quote:
Originally Posted by
RobNHood
Just tried it. When the edit control has the focus KeyDown messages go to the edit control
Well, then set the edit control styles EN_MULTILINE and EN_WANTRETURN, then handle EN_UPDATE for the edit control and check whether return was clicked (you can use GetKeyState API to do it)
Re: Processing Enter and Esc in CEdit
Okay that does seem to process the RETURN just fine but it still does not handle the ESCAPE how would I go about implementing that in the edit control? Never mind the ESCAPE was routed to the containing dialog so I overrode OnCancel there and redirected it to notify the edit control. Thank you so much for your help everything works great now.