Subclassed Listview not sending any notifications...
-
Tommy2k wrote: I guess i must have done something wrong subclassing this listview but i don't know what. Can you show the code?
class CContactlist : public CWindowImpl { private: CImageList ContactImageList; TimContact TimContactlist[256]; int NumberOfContactsLoaded; CStatic tHyperlink; CAnimateCtrl tAnim; int colormsg; CFont hLinkFont,hLinkFont2; public: DECLARE_WND_SUPERCLASS(NULL, CListViewCtrl::GetWndClassName()) BOOL PreTranslateMessage(MSG* pMsg); BEGIN_MSG_MAP(CContactlist) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) MESSAGE_HANDLER(WM_CTLCOLORSTATIC,OnCtrlColorStatic) MESSAGE_HANDLER(WM_CONTEXTMENU,OnContextMenu) NOTIFY_CODE_HANDLER(NM_CLICK,OnActivateItem) END_MSG_MAP() friend class CTimUser; CContactlist(); ~CContactlist(); void Setup(); void OnParentSize(HWND hWndParent); BOOL LoadImagelist(); void ShowCancelLogin(bool show); void AddContactToList(CAtlString * Username, CAtlString * Email, CAtlString * Nickname, int Status, bool Blocked); protected: // Handler prototypes (uncomment arguments if needed): // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/); LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled); LRESULT OnCtrlColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnActivateItem(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) { MessageBox("blah"); return 0; } }; It's the CLICK one that doesn't work... Thnx
-
class CContactlist : public CWindowImpl { private: CImageList ContactImageList; TimContact TimContactlist[256]; int NumberOfContactsLoaded; CStatic tHyperlink; CAnimateCtrl tAnim; int colormsg; CFont hLinkFont,hLinkFont2; public: DECLARE_WND_SUPERCLASS(NULL, CListViewCtrl::GetWndClassName()) BOOL PreTranslateMessage(MSG* pMsg); BEGIN_MSG_MAP(CContactlist) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) MESSAGE_HANDLER(WM_CTLCOLORSTATIC,OnCtrlColorStatic) MESSAGE_HANDLER(WM_CONTEXTMENU,OnContextMenu) NOTIFY_CODE_HANDLER(NM_CLICK,OnActivateItem) END_MSG_MAP() friend class CTimUser; CContactlist(); ~CContactlist(); void Setup(); void OnParentSize(HWND hWndParent); BOOL LoadImagelist(); void ShowCancelLogin(bool show); void AddContactToList(CAtlString * Username, CAtlString * Email, CAtlString * Nickname, int Status, bool Blocked); protected: // Handler prototypes (uncomment arguments if needed): // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/); LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled); LRESULT OnCtrlColorStatic(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnActivateItem(int idCtrl, LPNMHDR pnmh, BOOL& bHandled) { MessageBox("blah"); return 0; } }; It's the CLICK one that doesn't work... Thnx
Ok, what you want is to reflect notifications. For this you will have to add
REFLECT_NOTIFICATIONS()
to the bottom of the containing window's message map:BEGIN_MSG_MAP(thisClass)
...
REFLECT_NOTIFICATIONS()
END_MSG_MAP()Then, change your
NOTIFY_CODE_HANDLER
withREFLECTED_NOTIFY_CODE_HANDLER
. You may also want to add aDEFAULT_REFLECTION_HANDLER()
to the end of your List's message map. Things should work, now. -
Ok, what you want is to reflect notifications. For this you will have to add
REFLECT_NOTIFICATIONS()
to the bottom of the containing window's message map:BEGIN_MSG_MAP(thisClass)
...
REFLECT_NOTIFICATIONS()
END_MSG_MAP()Then, change your
NOTIFY_CODE_HANDLER
withREFLECTED_NOTIFY_CODE_HANDLER
. You may also want to add aDEFAULT_REFLECTION_HANDLER()
to the end of your List's message map. Things should work, now. -
What are the template arguments for CWindowImpl?
-
What are the template arguments for CWindowImpl?
-
Shouldn't this be:
class CContactlist : public CWindowImpl<CContactList, CListViewCtrl>
?
-
Shouldn't this be:
class CContactlist : public CWindowImpl<CContactList, CListViewCtrl>
?
-
Where is the list contained?
-
Where is the list contained?
-
Please show the code for the container's message map and class declaration. I'm on MSN: joao.fig@mail.telepac.pt