-
March 10th, 2011, 06:49 PM
#1
CTreeCtrl derived class communication to parent
Most of this discussion revolves around default MFC code from CodeWizard. I created an MFC project with a Visual Studio 2008 style.
There is a class derived from CTreeCtrl. The class is called CViewTree (not the "CTreeView" class). They created this derived CTreeCtrl class to handle a TTN_SHOW message for tooltips in its OnNotify message handler.
The CViewTree class is instantiated in a DockablePane class called CFileView. I'd like the CFileView class to receive message from the CViewTree class and process them for the "FIleView". The CViewTree class has access to the click and double click messages from the CTreeCtrl but the CFile Class does not appear to have this access.
What approach is used to handle this communication in applications that have this type of left hand FileView interface? How can I get a double click on the tree and handle in CFileView?
class CViewTree : public CTreeCtrl
{
// Construction
public:
CViewTree();
// Overrides
protected:
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
// Implementation
public:
virtual ~CViewTree();
protected:
DECLARE_MESSAGE_MAP()
};
class CFileView : public CDockablePane
{
// Construction
public:
CFileView();
void AdjustLayout();
void OnChangeVisualStyle();
// Attributes
protected:
CViewTree m_wndFileView;
CImageList m_FileViewImages;
CFileViewToolBar m_wndToolBar;
protected:
void FillFileView();
// Implementation
public:
virtual ~CFileView();
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
afx_msg void OnProperties();
afx_msg void OnFileOpen();
afx_msg void OnFileOpenWith();
afx_msg void OnDummyCompile();
afx_msg void OnEditCut();
afx_msg void OnEditCopy();
afx_msg void OnEditClear();
afx_msg void OnPaint();
afx_msg void OnSetFocus(CWnd* pOldWnd);
DECLARE_MESSAGE_MAP()
};
-
March 11th, 2011, 01:46 PM
#2
Re: CTreeCtrl derived class communication to parent
Class Wizard shows all the potential reflected messages for the class called CViewTree. Notifications ARE going to the parent window, CFileView, but they don't show up in Class Wizard. You have to hand code them.
class CFileView : public CDockablePane
{
//other stuff
afx_msg void OnTreeDblClick(NMHDR* pNMHDR, LRESULT* pResult);
};
Message map for the CFileView class
BEGIN_MESSAGE_MAP(CFileView, CDockablePane)
// others
ON_NOTIFY(NM_DBLCLK,4,OnTreeDblClick)
END_MESSAGE_MAP()
Handler in CFileView class
afx_msg void CFileView::OnTreeDblClick(NMHDR* pNMHDR, LRESULT* pResult)
{
//handler
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|