Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I created an MDI application and I want to show a tooltip containing document path when I move cursor on the relative tab (the same behaviour of Visual Studio).
I found this article:

How to obtain the absolute path of the tab(ToolTip) for mouse .[^]

but I cannot get path (or name) of the document. CMFCBaseTabCtrl struct contains a lot of informations such as tab index, but I cannot use this value to loop on open documents if I allow tab swapping or if I divide the View in two or more parts dragging and dropping a tab in the View.

Could you somebody please help me?

Thanks a lot
Posted

1 solution

Please extend the parent of your tab :) :

1. Its message map:
ON_REGISTERED_MESSAGE(AFX_WM_ON_GET_TAB_TOOLTIP, OnTabToolTipNeeded)

2. Its function:
C++
LRESULT CYourFrame::OnTabToolTipNeeded(WPARAM wParam, LPARAM lParam)
{
  if (m_cTabCtrl.GetSafeHwnd()) {
    CMFCTabToolTipInfo* pcInfo = (CMFCTabToolTipInfo*) lParam;
    if (pcInfo) {
      CString cszText;
      if (m_cTabCtrl.GetTabLabel(pcInfo->m_nTabIndex, cszText) &&
          cszText.GetLength()) {
        CYourView* pcView(DYNAMIC_DOWNCAST(CYourView, m_cTabCtrl.GetTabWnd(pcInfo->m_nTabIndex)));
        if (pcView->GetSafeHwnd()) {
          cszText += _T(" [");
          cszText += pcView->GetPath();
          cszText += _T("]");
        }
        pcInfo->m_strText = cszText;
      }
    }
  }
  return 0;
}
 
Share this answer
 
Comments
symreds 9-Feb-12 7:55am    
thank you very much!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900