Forward key to another controller
-
In a dialog I got a CEdit and a ListCtrl. And when I press any A-Z key in the ListCtrl I want that key to be forwarded to the edit controller and focus to be change so that continues writing will be in the CEdit. The solution I came up with is this. It appears to work. But I get a bad felling about this solution. Anyone know if this is a correct way of doing this
// m_pEdit is a pointer to the CEdit. void CMyListCtrl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { if( nChar >= 'a'&& nChar <= 'z' || nChar >= 'A'&& nChar <= 'Z') { m_pEdit->PostMessage( WM_CHAR , (WCHAR)nChar,MAKELPARAM(nRepCnt,nFlags) ); m_pEdit->SetFocus(); return; } CListCtrl::OnChar(nChar, nRepCnt, nFlags); }
Or should I do this from OnKeyDown instead? /Mathias S.