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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ESC Key on a CFormView

ESC Key on a CFormView

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 1 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.
  • N Offline
    N Offline
    netx2003
    wrote on last edited by
    #1

    I have a CFormView and I need to capture the ESC key. The control the has the focus always receive the OnChar but the form never does. I don't want to use an Accelerator nor any code on the controls. Any Ideas?

    M N 3 Replies Last reply
    0
    • N netx2003

      I have a CFormView and I need to capture the ESC key. The control the has the focus always receive the OnChar but the form never does. I don't want to use an Accelerator nor any code on the controls. Any Ideas?

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      Just a guess: Override PreTranslateMessage in your CFormView. Mazy "And the carpet needs a haircut, and the spotlight looks like a prison break And the telephone's out of cigarettes, and the balcony is on the make And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits

      1 Reply Last reply
      0
      • N netx2003

        I have a CFormView and I need to capture the ESC key. The control the has the focus always receive the OnChar but the form never does. I don't want to use an Accelerator nor any code on the controls. Any Ideas?

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

        PreTranslateMessage is never called on the CFormView

        D 1 Reply Last reply
        0
        • N netx2003

          PreTranslateMessage is never called on the CFormView

          D Offline
          D Offline
          dazinith
          wrote on last edited by
          #4

          thats how i did it.. here is some code from one of my dialogs that is derived from CFormView.. in my .h

          BOOL PreTranslateMessage(MSG\* pMsg);
          

          in my .cpp

          BOOL CST3WKSHT::PreTranslateMessage(MSG* pMsg)
          {
          CSCTaxApp* pApp = (CSCTaxApp*)AfxGetApp();
          if(pMsg->message==WM_KEYDOWN && pApp->m_bEnterAsTab)
          {
          if(pMsg->wParam==VK_RETURN)
          pMsg->wParam=VK_TAB;
          }
          return CFormView::PreTranslateMessage(pMsg);
          }

          this converts my keypresses from enters to tabs.. and it does work.. hope that helps still a newb.. cut me some slack :P -dz

          1 Reply Last reply
          0
          • N netx2003

            I have a CFormView and I need to capture the ESC key. The control the has the focus always receive the OnChar but the form never does. I don't want to use an Accelerator nor any code on the controls. Any Ideas?

            N Offline
            N Offline
            netx2003
            wrote on last edited by
            #5

            Thank for the help. I had a problem in my code: MSDN Library: PRB: Modal Dialog Box Prevents Calls to PreTranslateMessage ID: Q126874

            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