使用BCGControlBar时,如何捕获Workspace bar类上的树控件的消息?
				
					![]() 
					
					
					
						发表于2019-05-10
						回复:0
						查看:3459  |  
					
				 
				
					我想在MainFrame中捕获Workspace bar类上的树控件的通知消息 TVN_SELCHANGED,但是奇怪的是不能工作,而在非BCG的工程中确实可以的。
代码如下:
<pre class='brush: csharp'>      // WorkspaceBar.cpp : implementation of the CWorkspaceBar class
      //
      BEGIN_MESSAGE_MAP(CWorkspaceBar, CBCGSizingControlBar)
      //{{AFX_MSG_MAP(CWorkspaceBar)
      ON_WM_CREATE()
      ON_WM_SIZE()
      ON_NOTIFY(TVN_SELCHANGED, 1, OnSelectTree)
      //}}AFX_MSG_MAP
      END_MESSAGE_MAP()
      int CWorkspaceBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
      {
      ....
      // Create tabs window:
      if (!m_wndTabs.Create (CBCGTabWnd::STYLE_3D, rectDummy, this, 1))
      {
      TRACE0("Failed to create workspace tab window
");
      return -1; // fail to create
      }
      m_wndTabs.SetImageList (IDB_WORKSPACE, 16, RGB (255, 0, 255));
      // Create tree windows.
      // TODO: create your own tab windows here:
      const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES
      | 
      TVS_LINESATROOT | TVS_HASBUTTONS;
      if (!m_wndTree1.Create (dwViewStyle, rectDummy, &m_wndTabs, 2) ||
      !m_wndTree2.Create (dwViewStyle, rectDummy, &m_wndTabs, 3))
      {
      TRACE0("Failed to create workspace view
");
      return -1; // fail to create
      }
      ...
      }  
      void CWorkspaceBar::OnSelectTree(NMHDR* pNMHDR, LRESULT* pResult) 
      {
      NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
      *pResult = 0;
      }
      // WorkspaceBar.h : interface of the CWorkspaceBar class
      //
      // Generated message map functions
      protected:
      //{{AFX_MSG(CWorkspaceBar)
      afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
      afx_msg void OnSize(UINT nType, int cx, int cy);
      afx_msg void OnSelectTree(NMHDR* pNMHDR, LRESULT* pResult);
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
      };</pre>					
					
											
					
									 
			
登录 慧都网发表评论