The MFC Wizard created a project with a CWorkSpaceBar which in my case is actually based on CBCGPDockingControlBar, the MFC equivalent is CDockablePane. The wizard also created a m_wndTree based on CBCGPTreeCtrl (CTreeCtrl). It created it in its OnCreate() like this:
CRect rectDummy;
rectDummy.SetRectEmpty();
// Create tree control:
const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS;
if (!m_wndTree.Create(dwViewStyle, rectDummy, this, 1))
{
TRACE0("Failed to create workspace view\n");
return -1; // fail to create
}
Now I would like to handle some of the TreeView notifications so I added these to the CWorkSpaceBar message map:
ON_NOTIFY_REFLECT(TVN_ITEMEXPANDING, &CWorkSpaceBar::OnTvnItemExpanding)
ON_NOTIFY_REFLECT(TVN_GETDISPINFO, &CWorkSpaceBar::OnTvnGetDispInfo)
However, I'm not getting the notification messages? Is there something else I need to do to make it work?
You appear to be confusing the
ON_NOTIFY_REFLECTandON_NOTIFYhandlers; or rather, the windows for which those handlers should be defined.From what you have described, your
CWorkSpaceBarclass/object is the parent of the tree-view (CTreeCtrl) object; so, when an item is expanded in that tree-view, that parent pane receives aWM_NOTIFYmessage and the relevantON_NOTIFYhandler (if defined in the message-map) is called. TheON_NOTIFY_REFLECThandler allows the actual tree-view itself to intercept/receive the notification.In my projects, I have a similar situation, and the class(es) derived from
CDockablePane(such as myUserPane) have message map entries like the following, which work as expected:Note: The
IDR_USRTVis the ID value that I give to the tree-view, in itsCreatefunction, as shown below; in your example code, you have used the value of1(which may or may not be advisable).A basic outline for the
OnItemExpandmember function is as follows: