Re: ccombobox
"jan702189" <[email protected]>
| Newsgroups | gmane.comp.windows.wtl |
|---|---|
| Message-ID | <[email protected]> |
The compiler says there is an error at ATL_MSG_MAP(1) but I can't see anything wrong with it? --- In [email protected], "domehead100" <domehead100@...> wrote: > > > > I would do something like the code below. It simply uses CContainedWindowT to subclass the edit control and process it's messages in the message map of the parent (the combobox). > > > > class CComboView : public CWindowImpl<CComboView, CComboBox> > { > CContainedWindowT<CEdit> m_Edit; > public: > ============================================================ > CComboView() : m_Edit(this, 1) > { > } > ============================================================ > ~CComboView() > { > } > > protected: > BEGIN_MSG_MAP(CComboView) > MSG_WM_CREATE(OnCreate) > ALT_MSG_MAP(1) // edit control > MSG_WM_CHAR(OnEditChar) > REFLECT_NOTIFICATIONS() > END_MSG_MAP() > > ============================================================ > LRESULT OnCreate(LPCREATESTRUCT /*lpCreateStruct*/) > { > HWND hwndEdit = GetDlgItem(1001); > if(hwndEdit == NULL) > { > CPoint pt(::GetSystemMetrics(SM_CXFIXEDFRAME), ::GetSystemMetrics(SM_CYFIXEDFRAME)); > hwndEdit = ChildWindowFromPoint(pt); > } > ATLASSERT(hwndEdit != NULL); > ATLVERIFY(m_Edit.SubclassWindow(hwndEdit)); > return 0; > } > ============================================================ > LRESULT OnChar(TCHAR ch, UINT /*cRepeat*/, UINT /*flags*/) > { > switch(ch){ > case _T('\r'): > // process when the enter key is pressed, return 0 if processed message > } > SetMsgHandled(FALSE); > return 0; > } > }; > > --- In [email protected], "jan702189" <stetka@> wrote: > > > > The problem I'm having with the following code is that I can't enter any text into the edit control. CComboView.Create(...) is called from my app. > > > > > > WNDPROC lpfnEditWndProc; // original wndproc for the combo box > > // Prototypes > > LRESULT CALLBACK SubClassProc( HWND, UINT, WPARAM, LPARAM ); > > > > > > template< class T, class TBase = CWindow, class TWinTraits = CControlWinTraits > > > class ATL_NO_VTABLE CComboImpl : > > public CWindowImpl< T, TBase, TWinTraits > > > > > { > > public: > > CComboBox ctl; > > > > > > BEGIN_MSG_MAP(CComboView) > > > > MESSAGE_HANDLER(WM_CREATE, OnCreate) > > END_MSG_MAP() > > > > LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& > > /*bHandled*/) > > { > > > > //ModifyStyle(WS_CLIPCHILDREN, SS_NOTIFY); > > > > RECT rfc; > > rfc.bottom=200; > > rfc.left=rfc.top=0; > > rfc.right=800; > > ctl.Create(m_hWnd, rfc, NULL, WS_CHILD | WS_VISIBLE|CBS_DROPDOWN); > > > > lpfnEditWndProc = (WNDPROC) ::SetWindowLong(hEdit, > > GWL_WNDPROC, (DWORD) SubClassProc); > > > > return 0; > > } > > > > }; > > > > > > class CComboView : public CComboImpl<CComboView> > > { > > public: > > //DECLARE_WND_SUPERCLASS(NULL, CComboBox::GetWndClassName()) > > //DECLARE_WND_CLASS(NULL) > > BEGIN_MSG_MAP(CComboView) > > CHAIN_MSG_MAP(CComboImpl<CComboView>); > > END_MSG_MAP() > > }; > > LRESULT CALLBACK SubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) > > { > > switch (msg) > > { > > case WM_CHAR: > > //{ > > > > switch (wParam) > > { > > > > case VK_RETURN: > > > > /*TODO: work out what to do with combobox text*/ > > return 0; > > } > > //} > > } > > > > // Call the original window procedure for default processing. > > > > return CallWindowProc(lpfnEditWndProc, hwnd, > > msg, wParam, lParam); > > } > > > ------------------------------------ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/wtl/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/wtl/join (Yahoo! ID required) <*> To change settings via email: [email protected] [email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/