0

I made two groups of toolbar: `

    if (!m_wndToolBar1.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | CBRS_TOOLTIPS | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER |  CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || 
        !m_wndToolBar1.LoadToolBar(IDR_MAINFRAME_256))  return -1; 
    m_wndToolBar1.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockPane(&m_wndToolBar1);   
    

`

I make it in a DockPane and another one:

`

    if (!m_wndToolBar2.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
        !m_wndToolBar2.LoadToolBar(IDR_MAINFRAME_256_3D)) return -1;

    m_wndToolBar2.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);
    DockPane(&m_wndToolBar2);

Put tehe MESSAGE MAP:

    ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &CTunnelMainFrame::OnNeedText)

And the function:

BOOL CTunnelMainFrame::OnNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
    UINT_PTR nId = pNMHDR->idFrom - 1;
    CMFCToolBarButton* pBtnToolBar = m_wndToolBar1.GetButton(nId);

    if (pBtnToolBar)
    {
        TCHAR szBuff[64];
        ::LoadString(AfxGetResourceHandle(), pBtnToolBar->m_nID, szBuff, sizeof(szBuff) / sizeof(TCHAR));
pTTT->lpszText = szBuff;
pTTT->hinst = AfxGetResourceHandle();
    }

    return TRUE;
}

`

So, I expect that the tooltip will appear only on m_wndToolBar1's dock pane, but in fact it also appear on m_wndToolBar2's dock pane. But with STRINGTABLE ID (string message) that belongs to m_wndToolBar1. My question is how to disable tooltip on m_wndToolBar2's dock pane? or to make other OnNeedText funtion that only wokrs on m_wndToolBar2's dock pane?

Thanks~

Kang Gilar
  • 11
  • 1

1 Answers1

0
1)
BOOL CMainFrame::OnNeedText(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
    CPoint   point;
    GetCursorPos(&point);
    CRect rcToolbar1;
    m_wndToolBar.GetWindowRect(&rcToolbar1);
    if(rcToolbar1.PtInRect(point) == FALSE)
        return TRUE;
    
    UINT_PTR nId = pNMHDR->idFrom - 1;
    NMTTDISPINFO* pTTT = (NMTTDISPINFO*)pNMHDR;
    
    CMFCToolBarButton *pBtn1 = m_wndToolBar.GetButton(nId);
    if (pBtn1)
    {
        TCHAR szBuff[64];
        LoadString(AfxGetResourceHandle(), pBtn1->m_nID, szBuff, sizeof(szBuff) / sizeof(TCHAR));
        //_stprintf(szBuff, L"Controle ID:%d", pBtn1->m_nID);

        pTTT->lpszText = szBuff;
        pTTT->hinst = AfxGetResourceHandle();
    }
    return TRUE;
}

2)don't using TTN_NEEDTEXT, using the prompt instead, Resource View->Toolbar, set the m_wndToolBar1's prompt with text and set the m_wndToolBar2's prompt with empty text