Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Notification (WM_NOTIFY) by control inserted into CExtTabPageContainerFlatWnd Collapse All
Subject Author Date
Claus Fischer May 12, 2005 - 1:36 AM

Hi Folks;
My problem is, that I do not get notified by an Tree-Control inserted into an CExtTabPageContainerFlatWnd.


I subclassed from CExtTabPageContainerFlatWnd and inserted an CTreeCtrl into the TabPageContainer. I expect WM_NOTIFY messages to be sent to MyTabWnd, which ist parent of the TreeCtrl. How do I catch the WM_NOTIFY Message that should be sent by the TreeCtrl when the selection changed?


For clarification(?), here are some code-fragments:


CMyTabWnd : public CExtTabPageContainerFlatWnd
{
public:
  Create(CWnd* pParent);
public: 
 CTreeCtrl m_TreeCtrl;
}


CMyTabWnd::Create(CWnd* pParent)
{
 CExtTabPageContainerFlatWnd::Create(pParent);
 
 if( !m_TreeCtrl.Create(
  WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL|WS_TABSTOP
  |TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT
  |TVS_INFOTIP|TVS_DISABLEDRAGDROP
  |TVS_SINGLEEXPAND|TVS_SHOWSELALWAYS
  , CRect(0,0,0,0), this, UINT(IDC_STATIC) )
  )
 {
  TRACE0("Failed to create TreeCtrl\n");
  return FALSE;  // fail to create
 }
 m_TreeCtrl.SetFont( CFont::FromHandle( (HFONT)::GetStockObject(DEFAULT_GUI_FONT))


 VERIFY( PageInsert( &m_TreeCtrl, _T("Tree")  ) );


 return TRUE;
}


I tried to overwrite CMyTabWnd::OnNotify(...) but it was never called - overwriting OnHookNotifyMsg(...) did not work either.


Thanks for your help.
Joachim

Technical Support May 12, 2005 - 8:59 AM

The internal implementation of the CExtTabPageContainerWnd class changes identifiers of the windows which you insert as its pages. So, you cannot use the ON_NOTIFY macros directly. For example, if you created a tree control specified with IDC_STATIC, this macros does not work:

BEGIN_MESSAGE_MAP(CMyTabPageContainerWnd, CExtTabPageContainerWnd)
      //{{AFX_MSG_MAP(CMyTabPageContainerWnd)
      ON_NOTIFY(TVN_SELCHANGED, IDC_STATIC, OnSelchangedTree1)
      //}}AFX_MSG_MAP
END_MESSAGE_MAP()
You need to override the OnNotify virtual method. We have no idea why it is not called in your case. Your code should look like as follows:
class CMyTabPageContainerWnd : public CExtTabPageContainerWnd
{
      // Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CMyTabPageContainerWnd)
      protected:
      virtual BOOL OnNotify(WPARAM wParam, 
      LPARAM lParam, LRESULT* pResult);
      //}}AFX_VIRTUAL
 
      // Implementation
      protected:
      // Generated message map functions
      //{{AFX_MSG(CMyTabPageContainerWnd)
      //}}AFX_MSG
      DECLARE_MESSAGE_MAP()
}; // class CMyTabPageContainerWnd
 
 
BOOL CMyTabPageContainerWnd::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
{
      ASSERT(pResult != NULL);
      NMHDR* pNMHDR = (NMHDR*)lParam;
      HWND hWndCtrl = pNMHDR->hwndFrom;
 
      // get the child ID from the window itself
      UINT nID = ((UINT)(WORD)::GetDlgCtrlID( hWndCtrl ));
      UINT nIDTree = ((UINT)(WORD)::GetDlgCtrlID( m_TreeCtrl.m_hWnd ));
      int nCode = pNMHDR->code;
 
      ASSERT(hWndCtrl != NULL);
      ASSERT(::IsWindow(hWndCtrl));
 
      if( nCode == TVN_SELCHANGED && nID == nIDTree )
      {
            ...
            return;
      }
 
      return CExtTabPageContainerWnd::OnNotify(wParam, lParam, pResult);
}