I derived my own control from CEdit
and it behaves as I intend:
#define IsSHIFTpressed() ( (GetKeyState(VK_SHIFT) & (1 << (sizeof(SHORT)*8-1))) != 0 )
void CEditEx::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (IsCTRLpressed() && nChar == 2)
{
// Do something
return;
}
if (IsCTRLpressed() && nChar == 9)
{
// Do something
return;
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
However, I have two questions about how I am detecting the key press:
- Is it possible to detect CTRL being pressed from inside
OnChar
without the need to useGetKeyState
? - Are there any constants for comparing against
"b"
(2) and"i"
(9)? I only knew I needed to use those numeric values from when I debugged into the handler.