Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. PreTranslateMessage(), OnCancel()

PreTranslateMessage(), OnCancel()

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestiondatabase
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kumar_mk
    wrote on last edited by
    #1

    Dear members, i have a query, In my dialog box i have an Edit Control that takes numeric value, Now after typing the value in the edit box, i press RETURN key for some validation to take place, for this task i am handling the PreTranslateMessage() for the VK_RETURN message, Now the problem is when i highlight the CANCEL button (with tab button)in the dialog box and try to close the Dialog Box by pressing ENTER button it is not responding (the dialog box is not closing), the reason is obvious that since i am handling the PreTranslateMessage() it is not responding, but i also want the dialog to be closed when i hit the Enter button after highlighting the Cancel button, how can i accomplish this?? OR is there any other way to handle the RETURN key validation stuff than using PreTranslateMessage(), so that the Cancel button's original behaviour is not lost. Please Help!!!

    thanx in advance kumar

    M N 2 Replies Last reply
    0
    • K kumar_mk

      Dear members, i have a query, In my dialog box i have an Edit Control that takes numeric value, Now after typing the value in the edit box, i press RETURN key for some validation to take place, for this task i am handling the PreTranslateMessage() for the VK_RETURN message, Now the problem is when i highlight the CANCEL button (with tab button)in the dialog box and try to close the Dialog Box by pressing ENTER button it is not responding (the dialog box is not closing), the reason is obvious that since i am handling the PreTranslateMessage() it is not responding, but i also want the dialog to be closed when i hit the Enter button after highlighting the Cancel button, how can i accomplish this?? OR is there any other way to handle the RETURN key validation stuff than using PreTranslateMessage(), so that the Cancel button's original behaviour is not lost. Please Help!!!

      thanx in advance kumar

      M Offline
      M Offline
      Mr Brainley
      wrote on last edited by
      #2

      The usual approach in MFC when overriding such functions for certain events is to call the base-class implementation of that function afterwards. You just do all Preprocessing you need, and then you call the base-class implementation and propagate its return value.

      1 Reply Last reply
      0
      • K kumar_mk

        Dear members, i have a query, In my dialog box i have an Edit Control that takes numeric value, Now after typing the value in the edit box, i press RETURN key for some validation to take place, for this task i am handling the PreTranslateMessage() for the VK_RETURN message, Now the problem is when i highlight the CANCEL button (with tab button)in the dialog box and try to close the Dialog Box by pressing ENTER button it is not responding (the dialog box is not closing), the reason is obvious that since i am handling the PreTranslateMessage() it is not responding, but i also want the dialog to be closed when i hit the Enter button after highlighting the Cancel button, how can i accomplish this?? OR is there any other way to handle the RETURN key validation stuff than using PreTranslateMessage(), so that the Cancel button's original behaviour is not lost. Please Help!!!

        thanx in advance kumar

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #3

        Along with the checking of VK_RETURN, check whether the handle is that of edit control. if( WM_KEYDOWN == pMsg->message ) { if( VK_RETURN == pMsg->wParam && m_edit.m_hWnd == pMsg->hwnd )// m_edit is the control variable of the edit control { // do ur computation return TRUE; } }

        nave

        K 1 Reply Last reply
        0
        • N Naveen

          Along with the checking of VK_RETURN, check whether the handle is that of edit control. if( WM_KEYDOWN == pMsg->message ) { if( VK_RETURN == pMsg->wParam && m_edit.m_hWnd == pMsg->hwnd )// m_edit is the control variable of the edit control { // do ur computation return TRUE; } }

          nave

          K Offline
          K Offline
          kumar_mk
          wrote on last edited by
          #4

          thanks a lot Naveen, its working:)

          thanx in advance kumar_windows

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups