Capturing the numpad presses
-
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
-
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
-
It's the view that receives key-down messages and not your CFrameWnd derived window Nish p.s. from cafe. so anony post
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
-
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
-
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! :) ------------------------------
-
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! :) ------------------------------
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