CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2013
    Location
    USA
    Posts
    30

    Exclamation 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.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    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)?
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2013
    Location
    USA
    Posts
    30

    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.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: Processing Enter and Esc in CEdit

    Quote Originally Posted by RobNHood View Post
    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)
    Victor Nijegorodov

  5. #5
    Join Date
    Jul 2013
    Location
    USA
    Posts
    30

    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.
    Last edited by RobNHood; July 8th, 2013 at 06:06 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured