Shift + VK_LEFT
-
Is there any possibility to catch shift + left key without mess up
PreTranslateMessage
? I have tried this:void CGridCtrlExt::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call defaultif(VK\_LEFT == nChar || VK\_RIGHT == nChar) TRACE1(">>>%d", nChar); CGridCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
I see TRACE message ... but when I wrote:
void CGridCtrlExt::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call defaultif((VK\_LEFT == nChar || VK\_RIGHT == nChar) && GetKeyState(VK\_SHIFT) < 0) TRACE1(">>>%d", nChar); CGridCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
I saw nothing ... can you help me out, please ? Thank you.
-
Is there any possibility to catch shift + left key without mess up
PreTranslateMessage
? I have tried this:void CGridCtrlExt::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call defaultif(VK\_LEFT == nChar || VK\_RIGHT == nChar) TRACE1(">>>%d", nChar); CGridCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
I see TRACE message ... but when I wrote:
void CGridCtrlExt::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call defaultif((VK\_LEFT == nChar || VK\_RIGHT == nChar) && GetKeyState(VK\_SHIFT) < 0) TRACE1(">>>%d", nChar); CGridCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
I saw nothing ... can you help me out, please ? Thank you.
It should work that way. But it will not work if those key combinations are "eaten" by an existing pre-translation. You may test that by using the first version with an extended trace:
TRACE1(">>>%d, state %x", nChar, GetKeyState(VK_SHIFT));
If the above is not called with shift key down, it is probably "eaten". Then you must use
PreTranslateMessage
or try to disable the existing translation. -
It should work that way. But it will not work if those key combinations are "eaten" by an existing pre-translation. You may test that by using the first version with an extended trace:
TRACE1(">>>%d, state %x", nChar, GetKeyState(VK_SHIFT));
If the above is not called with shift key down, it is probably "eaten". Then you must use
PreTranslateMessage
or try to disable the existing translation. -
Is there any possibility to catch shift + left key without mess up
PreTranslateMessage
? I have tried this:void CGridCtrlExt::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call defaultif(VK\_LEFT == nChar || VK\_RIGHT == nChar) TRACE1(">>>%d", nChar); CGridCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
I see TRACE message ... but when I wrote:
void CGridCtrlExt::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call defaultif((VK\_LEFT == nChar || VK\_RIGHT == nChar) && GetKeyState(VK\_SHIFT) < 0) TRACE1(">>>%d", nChar); CGridCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
I saw nothing ... can you help me out, please ? Thank you.
-
It should work that way. But it will not work if those key combinations are "eaten" by an existing pre-translation. You may test that by using the first version with an extended trace:
TRACE1(">>>%d, state %x", nChar, GetKeyState(VK_SHIFT));
If the above is not called with shift key down, it is probably "eaten". Then you must use
PreTranslateMessage
or try to disable the existing translation.Strange ... I have checked if parent of
CGridCtrlExt
(CGridCtrl
), hasPreTranslateMessage
, but no, has not ... more over, I overrideCGridCtrlExt::OnChar
,CGridCtrlExt::OnSysChar
,CGridCtrlExt::OnSysKeyDown
, none of them tell me when I press the shift key ... weird ... I don't know where to search the issue ... -
Strange ... I have checked if parent of
CGridCtrlExt
(CGridCtrl
), hasPreTranslateMessage
, but no, has not ... more over, I overrideCGridCtrlExt::OnChar
,CGridCtrlExt::OnSysChar
,CGridCtrlExt::OnSysKeyDown
, none of them tell me when I press the shift key ... weird ... I don't know where to search the issue ...I don't know which
CGridCtrl
you are using. The keys may be also catched by an underlying Windows control so that you don't see the translator source. If there is some action associated, you should recognize it. What happens when pressing Shift Left/Right on a wide item? You may spend some more time for investigation or just implement your ownPreTranslateMessage
handler. -
I have just tried this and it all works as per the documentation. I can only assume that these keys are being trapped by the
CGridCtrlExt
control somehow. -
I don't know which
CGridCtrl
you are using. The keys may be also catched by an underlying Windows control so that you don't see the translator source. If there is some action associated, you should recognize it. What happens when pressing Shift Left/Right on a wide item? You may spend some more time for investigation or just implement your ownPreTranslateMessage
handler. -
Neither
CGridCtrlExt
hasPreTranslateMessage
, or something that could trap the shift key ... I can not understand what happen ... -
I have not used that so far. But I'm quite sure that the arrow keys are used to select cells when the Shift key is pressed too.
-
It should work that way. But it will not work if those key combinations are "eaten" by an existing pre-translation. You may test that by using the first version with an extended trace:
TRACE1(">>>%d, state %x", nChar, GetKeyState(VK_SHIFT));
If the above is not called with shift key down, it is probably "eaten". Then you must use
PreTranslateMessage
or try to disable the existing translation.I guess it is my mistake !!! : I already have an accelerator, shift + left key, on menu item command ... if this is the cause, is there any possibility to know in CGridCtrlExt, of on CDialog which contain this control, to know when I pressed Shift and left key ?
-
Do you have the source of that class to check? The only real answer is to use your debugger and inspect all the values that are set when the key combination is pressed.
-
I guess it is my mistake !!! : I already have an accelerator, shift + left key, on menu item command ... if this is the cause, is there any possibility to know in CGridCtrlExt, of on CDialog which contain this control, to know when I pressed Shift and left key ?
If you have a global accelerator you have three options:
- From the accelerator handling check if your grid control is active and pass the message to that if so
- Add another accelerator table to your grid control
- Use PreTranslateMessage in your grid control
-
If you have a global accelerator you have three options:
- From the accelerator handling check if your grid control is active and pass the message to that if so
- Add another accelerator table to your grid control
- Use PreTranslateMessage in your grid control
-
If you have a global accelerator you have three options:
- From the accelerator handling check if your grid control is active and pass the message to that if so
- Add another accelerator table to your grid control
- Use PreTranslateMessage in your grid control