Subclassing
-
I want to subclass some combobox controls on a dialog to handle WM_KEYDOWN msg (to delete contents using DEL key). 1. I`m using CContainedWindow. I use the function: OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags) with MSG_WM_KEYDOWN in ALT_MSG_MAP(1). For one control, it's ok (works fine), but what if I want to subclass more than one and redirect all WM_KEYDOWN msgs to the same function ? How can I tell what control is receiving the message ? The m_hWnd member points to my dialog wnd. 2. I also tried the DDX way, using DDX_CONTROL and defining: class CCombo: public CWindowImpl and defining my controls of this class, but the compiler gives me an error saying that SubclassWindow is not a member of CComboBoxT How can I do it using #1 and what am I doing wrong with #2 ? Thanks.
-
I want to subclass some combobox controls on a dialog to handle WM_KEYDOWN msg (to delete contents using DEL key). 1. I`m using CContainedWindow. I use the function: OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags) with MSG_WM_KEYDOWN in ALT_MSG_MAP(1). For one control, it's ok (works fine), but what if I want to subclass more than one and redirect all WM_KEYDOWN msgs to the same function ? How can I tell what control is receiving the message ? The m_hWnd member points to my dialog wnd. 2. I also tried the DDX way, using DDX_CONTROL and defining: class CCombo: public CWindowImpl and defining my controls of this class, but the compiler gives me an error saying that SubclassWindow is not a member of CComboBoxT How can I do it using #1 and what am I doing wrong with #2 ? Thanks.
- See
CWindowImpl::GetCurrentMessage()
. You'll find the recipient HWND in the MSG-struct, i.e.GetCurrentMessage()->hwnd
. 2) That's because CComboBoxT doesn't derive from CWindowImpl which is the template which implements SubclassWindow. CComboBoxT is just a wrapper for an already existing window class, thus it isn't supposed to subclass another class. I never use DDX-stuff, so I wouldn't know how to deal with it. :shrug: -- Watcha' gonna do, when Hulkamania runs wild on you!?
- See