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. Capturing the numpad presses

Capturing the numpad presses

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicsquestion
6 Posts 4 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.
  • M Offline
    M Offline
    Mark Donkers
    wrote on last edited by
    #1

    Hello again everyone, and Happy New Year. I'm relatively new to VC++ so I'll try to explain this the best I can. Here's my situation... I have an SDI app where the MainFrm is CSplitterWnd'ed into several different views. I have one view that is a "keypad" (CView) with a bitmap that resembles a standard keyboard numpad. If the user presses any numpad buttons, I want that view to "see" and process those window messages. The following snippet is how I'm trying to do it, but it doesn't seem to receive any messages. What am I missing?? // ================================================================== void CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { ASSERT( GetActiveDocument() ); CClocksterDoc* pDoc = static_cast(GetActiveDocument()); int iQty = 0; switch(nChar) { case VK_NUMPAD1: iQty = OES_KEY_01; break; case VK_NUMPAD2: iQty = OES_KEY_02; break; case VK_NUMPAD3: iQty = OES_KEY_03; break; ...... } if( iQty > 0 ) { pDoc->DoPurchaseRequest( iQty ); } CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags); } // ================================================================== I hope explained this well enough. :confused: Thanks... Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope -- Daniel Burnham

    L A 2 Replies Last reply
    0
    • M Mark Donkers

      Hello again everyone, and Happy New Year. I'm relatively new to VC++ so I'll try to explain this the best I can. Here's my situation... I have an SDI app where the MainFrm is CSplitterWnd'ed into several different views. I have one view that is a "keypad" (CView) with a bitmap that resembles a standard keyboard numpad. If the user presses any numpad buttons, I want that view to "see" and process those window messages. The following snippet is how I'm trying to do it, but it doesn't seem to receive any messages. What am I missing?? // ================================================================== void CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { ASSERT( GetActiveDocument() ); CClocksterDoc* pDoc = static_cast(GetActiveDocument()); int iQty = 0; switch(nChar) { case VK_NUMPAD1: iQty = OES_KEY_01; break; case VK_NUMPAD2: iQty = OES_KEY_02; break; case VK_NUMPAD3: iQty = OES_KEY_03; break; ...... } if( iQty > 0 ) { pDoc->DoPurchaseRequest( iQty ); } CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags); } // ================================================================== I hope explained this well enough. :confused: Thanks... Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope -- Daniel Burnham

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      It's the view that receives key-down messages and not your CFrameWnd derived window Nish p.s. from cafe. so anony post

      M 1 Reply Last reply
      0
      • L Lost User

        It's the view that receives key-down messages and not your CFrameWnd derived window Nish p.s. from cafe. so anony post

        M Offline
        M Offline
        Mark Donkers
        wrote on last edited by
        #3

        Thanks Nish. That works, but only when it has the focus. Is there a way to force the view to always receive the key-down message?? Thanks. Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope -- Daniel Burnham

        1 Reply Last reply
        0
        • M Mark Donkers

          Hello again everyone, and Happy New Year. I'm relatively new to VC++ so I'll try to explain this the best I can. Here's my situation... I have an SDI app where the MainFrm is CSplitterWnd'ed into several different views. I have one view that is a "keypad" (CView) with a bitmap that resembles a standard keyboard numpad. If the user presses any numpad buttons, I want that view to "see" and process those window messages. The following snippet is how I'm trying to do it, but it doesn't seem to receive any messages. What am I missing?? // ================================================================== void CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { ASSERT( GetActiveDocument() ); CClocksterDoc* pDoc = static_cast(GetActiveDocument()); int iQty = 0; switch(nChar) { case VK_NUMPAD1: iQty = OES_KEY_01; break; case VK_NUMPAD2: iQty = OES_KEY_02; break; case VK_NUMPAD3: iQty = OES_KEY_03; break; ...... } if( iQty > 0 ) { pDoc->DoPurchaseRequest( iQty ); } CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags); } // ================================================================== I hope explained this well enough. :confused: Thanks... Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope -- Daniel Burnham

          A Offline
          A Offline
          AJ123
          wrote on last edited by
          #4

          You maybe interested in system wide event hooks. Lookup SetWindowsHookEx

          R 1 Reply Last reply
          0
          • A AJ123

            You maybe interested in system wide event hooks. Lookup SetWindowsHookEx

            R Offline
            R Offline
            Rickard Andersson20
            wrote on last edited by
            #5

            Just telling you that you have to do all hooks in a DLL if you want to catch when a key is pressed while your app is in no focus! :) ------------------------------ ©0d3 ©®4©k3® - That's me! :) ------------------------------

            M 1 Reply Last reply
            0
            • R Rickard Andersson20

              Just telling you that you have to do all hooks in a DLL if you want to catch when a key is pressed while your app is in no focus! :) ------------------------------ ©0d3 ©®4©k3® - That's me! :) ------------------------------

              M Offline
              M Offline
              Mark Donkers
              wrote on last edited by
              #6

              Richard Jacko & Rickard Andersson & All, First, thanks for the reply. I think I'm headed in the right direction. Secondly, I'm very new to Windows programming so I'd like to apologize for my "Windows ignorance" :rolleyes: . Please bear with me... From reading the docs on SetWindowsHookEx, I assume that I want to set the idHook = WH_KEYBOARD, right? Then, I have to write a DLL with a procedure that will handle the message (which I've never done). Is this all correct? :confused: Thanks. Marcus Make no little plans; they have no magic to stir your blood to action. Make big plans, aim high in work and hope -- Daniel Burnham

              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