Re: Please help: trying to capture Enter Key in ComboBox within ToolBar
On Mar 23, 1:25 pm, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
Well that is frustrating. I am not sure what could be causing those
messages to get buried. If I watch with Spy++ I see the keydown and
onchar messages triggered in the edit control window, but they are not
raised anywhere else and they are not hitting my handlers.
Strange
Jeff
You said that the SubclassWindow call is getting called already. Is m_xEdit
of type CComboEdit? Is CComboEdit::PreTranslateMessage getting called?
AliR.
Yes, SubClassWindow inside of MyCombo::OnCtlColor is being hit.
Yes, m_xEdit is of type CComboEdit.
No, CComboEdit::PreTranslateMessage is not getting hit.
Also, I have a TRACE in the constructor of CComboEdit which is being
hit.
Here is my complete h and cpp for CComboEdit:
class CComboEdit : public CEdit
{
public:
CComboEdit();
protected:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CComboEdit)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CComboEdit();
// Generated message map functions
public:
//{{AFX_MSG(CComboEdit)
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg BOOL PreTranslateMessage(MSG* pMsg) ;
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CComboEdit::CComboEdit()
{
TRACE0("CComboEdit created");
}
CComboEdit::~CComboEdit()
{
}
BEGIN_MESSAGE_MAP(CComboEdit, CEdit)
//{{AFX_MSG_MAP(CComboEdit)
ON_WM_CHAR()
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CComboEdit::PreTranslateMessage(MSG* pMsg)
{
TRACE0("PRETRANSLATEMESSAGE");
if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP)
{
if (pMsg->wParam == VK_RETURN)
{
//the enter key was pressed
TRACE0("ENTER");
}
}
return CEdit::PreTranslateMessage(pMsg);
}
void CComboEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
TRACE0("ONKEYDOWN");
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CComboEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
TRACE0("ONCHAR");
CEdit::OnChar(nChar, nRepCnt, nFlags);
}