I have this code:
BOOL CChristianLifeMinistryStudentMaterialDlg::PreTranslateMessage(MSG* pMsg)
{
BOOL bNoDispatch, bDealtWith;
bDealtWith = FALSE;
if (IsCTRLpressed() &&
pMsg->message == WM_KEYDOWN && pMsg->wParam == _TINT(_T('I')))
{
if (EncodeText(pMsg->hwnd, _T("i")))
{
// Eat it.
bNoDispatch = TRUE;
bDealtWith = TRUE;
}
}
else if (IsCTRLpressed() &&
pMsg->message == WM_KEYDOWN && pMsg->wParam == _TINT(_T('B')))
{
if (EncodeText(pMsg->hwnd, _T("b")))
{
// Eat it.
bNoDispatch = TRUE;
bDealtWith = TRUE;
}
}
if (!bDealtWith)
bNoDispatch = CDialogEx::PreTranslateMessage(pMsg);
return bNoDispatch;
}
Originally, I had 3 CEdit
controls on my dialog. When you used this key press it performed an action as above on the selection in the edit controls.
I changed the controls from CEdit
to CComboBox
. They are editable type. I adjusted EncodeText
to use GetEditSel
and SetEditSel
.
Only problem is now when I am editing text in the combo box. I select some of the text and press CTRL + I and nothing happens. The PTM of my dialog is not getting intercepted.
Visual Example
In this CEdit
control I can select text:
Then I use one of the hot keys, eg: CTRL + B and it still works:
But, when I select some text in the editable CComboBox
and use the same hot key:
In this case it is not working.
I have assumed it is because technically I am inside a embedded "Edit" control of the combo. How do I still detect the hot keys now that I am using selected text inside a combo?