从选项卡获取文档路径 [英] Get document path from tab

查看:103
本文介绍了从选项卡获取文档路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我创建了一个MDI应用程序,并希望在相对选项卡上移动光标时显示包含文档路径的工具提示(与Visual Studio的行为相同).
我找到了这篇文章:

如何获取标签页的绝对路径( [ ^ ]

但我无法获取文档的路径(或名称). CMFCBaseTabCtrl结构包含很多信息,例如选项卡索引,但是如果允许选项卡交换,或者将视图分为两个或更多部分,则不能使用该值在打开的文档上循环. />
有人可以帮我吗?

非常感谢

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

推荐答案

请扩展选项卡的父级:):

1.其消息图:
ON_REGISTERED_MESSAGE(AFX_WM_ON_GET_TAB_TOOLTIP, OnTabToolTipNeeded)

2.其功能:
Please extend the parent of your tab :) :

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

2. Its function:
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;
}


这篇关于从选项卡获取文档路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆