// Header file CLeftView.h class CLeftView : public CTreeCtrl { public: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: DECLARE_MESSAGE_MAP() afx_msg void OnTvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult); afx_msg void OnTvnEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult); private: bool m_bEditLabel; }; // Source file CLeftView.cpp CLeftView::CLeftView() { m_bEditLabel = false; } BEGIN_MESSAGE_MAP(CLeftView, CTreeCtrl) ON_NOTIFY_REFLECT(TVN_BEGINLABELEDIT, &CDMTreeCtrl::OnTvnBeginlabeledit) ON_NOTIFY_REFLECT(TVN_ENDLABELEDIT, &CDMTreeCtrl::OnTvnEndlabeledit) END_MESSAGE_MAP() void CLeftView::OnTvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTVDISPINFO pTVDispInfo = reinterpret_cast<LPNMTVDISPINFO>(pNMHDR); m_bEditLabel = true; *pResult = 0; } void CLeftView::OnTvnEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTVDISPINFO pTVDispInfo = reinterpret_cast<LPNMTVDISPINFO>(pNMHDR); m_bEditLabel = false; // TODO: Add your control notification handler code here *pResult = 0; } BOOL CLeftView::PreTranslateMessage(MSG* pMsg) { if( m_bEditLabel) { ::TranslateMessage(pMsg); ::DispatchMessage(pMsg); return TRUE; } return CTreeView::PreTranslateMessage(pMsg); } |
No comments:
Post a Comment