Prev: Synchronizing resource preprocessor definitions and regular definitions
Next: CreateProcess( ... ) always on top of my app.
From: hamishd on 16 Apr 2010 06:29 How do I catch a SHIFT + TAB ? BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN){ if(pMsg->wParam == VK_TAB && pMsg->lParam == VK_SHIFT){ //do stuff } return CFrameWnd::PreTranslateMessage(pMsg); }
From: David Lowndes on 16 Apr 2010 06:49 >How do I catch a SHIFT + TAB ? Are you trying to simulate dialog navigation handling? If you are, have a look at IsDialogMessage - it can be used for any window, not just a dialog. Dave
From: hamishd on 16 Apr 2010 07:36 On Apr 16, 10:49 pm, David Lowndes <Dav...(a)example.invalid> wrote: > >How do I catch a SHIFT + TAB ? > > Are you trying to simulate dialog navigation handling? If you are, > have a look at IsDialogMessage - it can be used for any window, not > just a dialog. Not trying to simulate. The dialog has no controls, just drawings.
From: David Lowndes on 16 Apr 2010 07:57 >> >How do I catch a SHIFT + TAB ? >> >> Are you trying to simulate dialog navigation handling? If you are, >> have a look at IsDialogMessage - it can be used for any window, not >> just a dialog. > >Not trying to simulate. The dialog has no controls, just drawings. So, out of interest, why do you need to handle Shift+Tab? The answer to your question is to use GetKeyState. Dave
From: Joseph M. Newcomer on 16 Apr 2010 09:52
See below... On Fri, 16 Apr 2010 03:29:30 -0700 (PDT), hamishd <hamish.dean(a)gmail.com> wrote: >How do I catch a SHIFT + TAB ? > > >BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) >{ > if (pMsg->message == WM_KEYDOWN){ > if(pMsg->wParam == VK_TAB && pMsg->lParam == VK_SHIFT){ **** Did you read the specification of WM_KEYDOWN? Where, in that description, does it tell you that if wParam == VK_TAB that lParam can == VK_SHIFT? Really, seriously, did you read the description AT ALL? Just in case, here it is: lParam Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. 0-15 Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative. 16-23 Specifies the scan code. The value depends on the OEM. 24 Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0. 25-28 Reserved; do not use. 29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message. 30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is zero if the key is up. 31 Specifies the transition state. The value is always zero for a WM_KEYDOWN message. Where, in the above, does it explain about how the lParam can be == VK_SHIFT? Only if the repeat count happens to be == VK_SHIFT, and the scan code for VK_TAB happens to be 0 (both have zero probability). Actually, GetKeyState() can be used when you get a VK_TAB to see if the shift key was held down at the time: if(GetKeyState(VK_SHIFT) < 0) **** > //do stuff > } > > return CFrameWnd::PreTranslateMessage(pMsg); >} Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm |