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

Enter

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 2 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.
  • J Offline
    J Offline
    Johnny Peszek
    wrote on last edited by
    #1

    Hi! In a dialog based application with a multiline edit box I’m trying to count the number of enter hits. I tried to use code like this: void CNanoDlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { if(nChar==VK_RETURN) { counter++; } CDialog::OnChar(nChar, nRepCnt, nFlags); } The code doesn’t work. Any Ideas? Thanks in advance.

    V 1 Reply Last reply
    0
    • J Johnny Peszek

      Hi! In a dialog based application with a multiline edit box I’m trying to count the number of enter hits. I tried to use code like this: void CNanoDlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { if(nChar==VK_RETURN) { counter++; } CDialog::OnChar(nChar, nRepCnt, nFlags); } The code doesn’t work. Any Ideas? Thanks in advance.

      V Offline
      V Offline
      V 0
      wrote on last edited by
      #2

      Do this: message map: ON_WM_GETDLGCODE() header file: afx_msg UINT OnGetDlgCode( ); in code: UINT CtrlFlexArray::OnGetDlgCode(){ return DLGC_WANTALLKEYS; } //end function OnGetDlgCode good luck. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

      J 1 Reply Last reply
      0
      • V V 0

        Do this: message map: ON_WM_GETDLGCODE() header file: afx_msg UINT OnGetDlgCode( ); in code: UINT CtrlFlexArray::OnGetDlgCode(){ return DLGC_WANTALLKEYS; } //end function OnGetDlgCode good luck. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

        J Offline
        J Offline
        Johnny Peszek
        wrote on last edited by
        #3

        I almost got it. But when I press enter or any different key in the edit box the function OnGetDlgCode() returns always the same result so I’m not able to count enter hits. Am I missing something? Regards.

        V 1 Reply Last reply
        0
        • J Johnny Peszek

          I almost got it. But when I press enter or any different key in the edit box the function OnGetDlgCode() returns always the same result so I’m not able to count enter hits. Am I missing something? Regards.

          V Offline
          V Offline
          V 0
          wrote on last edited by
          #4

          I dunno, Do you handle your keystrokes in OnKeyDown (or Up) messagehandler? in message map: ON_WM_KEYDOWN() in header: afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); in code: void yourclas::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags){ //your code here } if you do have this I wouldn't know, what you could have forgotten. Hope this helps. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

          J 1 Reply Last reply
          0
          • V V 0

            I dunno, Do you handle your keystrokes in OnKeyDown (or Up) messagehandler? in message map: ON_WM_KEYDOWN() in header: afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); in code: void yourclas::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags){ //your code here } if you do have this I wouldn't know, what you could have forgotten. Hope this helps. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

            J Offline
            J Offline
            Johnny Peszek
            wrote on last edited by
            #5

            The code that you wrote works fine in SDI or MDI application. But I have dialog based application with edit box in which I want to count enter hits.

            V 1 Reply Last reply
            0
            • J Johnny Peszek

              The code that you wrote works fine in SDI or MDI application. But I have dialog based application with edit box in which I want to count enter hits.

              V Offline
              V Offline
              V 0
              wrote on last edited by
              #6

              Try adding a button to your dialog, set it as default button and make it invisible. (note: it could take the ESC button too) (note: if it doesn't work, set it's focus explicitly) just an idea, hope it works. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

              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