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 General Discussion » Using CExtCTA template class? Collapse All
Subject Author Date
Jase Wolfe Mar 5, 2008 - 12:53 PM

I would like to use the CExtCTA template class to wrap a CTreeCtrl based class in order to have the tooltips style match that of the theme.

In my derived class, I have overridden OnToolHitTest and OnToolTipText in order to show my own custom tooltip text over a node, instead of the default tooltip.

I have created the class as

public class CTreeCtrlTT : CExtCTA < CTreeCtrl >
{
/* Class header information */
};

But this does not seem to do anything as the tooltips are not themed. What else needs to be implemented to have Prof-UIS draw the tooltips?

Thanks in advance.

Technical Support Mar 8, 2008 - 11:10 AM

You should not use LPSTR_TEXTCALLBACK in your implementation of OnToolHitTest() because it’s not supported by the CExtCTA template class. Here is the correct implementation:

int CTreeCtrlTT::OnToolHitTest(CPoint point, TOOLINFO * pTI) const
{
UINT nFlags;
HTREEITEM hItem = HitTest( point, &nFlags );
      if( nFlags & TVHT_ONITEMLABEL )
      {
            RECT rect;
            GetItemRect( hItem, &rect, TRUE );
            pTI->hwnd = m_hWnd;
            pTI->uId = (UINT)hItem;
/////////////////////////////////////////////////////////////////////////////
// PROF-UIS TECH SUPPORT: beginning of the modified code block
// The LPSTR_TEXTCALLBACK value is not supported by the CExtCTA template class.
            //pTI->lpszText = LPSTR_TEXTCALLBACK;
            COleDateTime _time = COleDateTime::GetCurrentTime();
            CString strComposedToolTopText;
            strComposedToolTopText.Format(
                  _T("Cool tip for tree item:\n")
                  _T("    - Item hadle is = %p = 0x%08X\n")
                  _T("    - Item rect is (left=%d,top=%d,right=%d,bottom=%d)\n")
                  _T("    - Hit testing flags = 0x%08X\n")
                  _T("    - Activation item is %s\n")
                  _T("    - Tick count is %d")
                  ,
                  hItem, hItem,
                  rect.left, rect.top, rect.right, rect.bottom,
                  nFlags,
                  LPCTSTR( _time.Format() ),
                  ::GetTickCount()
                  );
            pTI->lpszText = _tcsdup( LPCTSTR(strComposedToolTopText) );
// PROF-UIS TECH SUPPORT: end of the modified code block
/////////////////////////////////////////////////////////////////////////////
            pTI->rect = rect;
            return pTI->uId;
      }
      return -1;
}
We sent you a modified version of you project.

Jase Wolfe Mar 6, 2008 - 9:01 AM

Ok, I have sent a zipped up project called Sample.zip that uses the CTreeCtrlTT class derived from CTreeCtrl and wrapped in CExtCTA.

Technical Support Mar 6, 2008 - 5:41 AM

The MFC library contains one internal instance of the CToolTipCtrl window internally for each MFC-based thread. This tooltip control can be activated automatically by any window. You can override the CWnd::OnToolHitTest() virtual method for providing MFC framework with information required for tooltip activation. The CExtCTA template class uses this approach but it prevents activation of MFC’s internal tooltip window and the CExtPopupMenuTipWnd window instead. We tested our template class with different common controls and we did not face any problems. But there are a lot of situations in MFC that are related to timers and idle time processing which may cause both MFC and Prof-UIS tooltips not displayed at all. We need a small test project which demonstrates the problem so that we can figure out what’s wrong. You can send it to the support mail box at this web site.