1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
21 #include "Tooltip.h"
\r
24 BEGIN_MESSAGE_MAP(CToolTips, CToolTipCtrl)
\r
25 ON_NOTIFY_REFLECT_EX( TTN_NEEDTEXT, &CToolTips::OnTtnNeedText )
\r
30 BOOL CToolTips::OnTtnNeedText(NMHDR *pNMHDR, LRESULT *pResult)
\r
32 if (pNMHDR->code == TTN_NEEDTEXTW)
\r
34 LPNMTTDISPINFO lpnmtdi = (LPNMTTDISPINFO)pNMHDR;
\r
35 UINT_PTR nID = pNMHDR->idFrom;
\r
37 if (lpnmtdi->uFlags & TTF_IDISHWND)
\r
39 // idFrom is actually the HWND of the tool
\r
40 nID = ::GetDlgCtrlID((HWND)nID);
\r
42 if (toolTextMap.find(nID) != toolTextMap.end())
\r
44 lpnmtdi->lpszText = (LPTSTR)(LPCTSTR)(CString)toolTextMap[nID];
\r
45 lpnmtdi->hinst = AfxGetResourceHandle();
\r
53 BOOL CToolTips::AddTool(CWnd* pWnd, UINT nIDText, LPCRECT lpRectTool /* = NULL */, UINT_PTR nIDTool /* = 0 */)
\r
56 sTemp.LoadString(nIDText);
\r
57 // tooltips can't handle \t and single \n, only spaces and \r\n
\r
58 sTemp.Replace('\t', ' ');
\r
59 sTemp.Replace(_T("\r\n"), _T("\n"));
\r
60 sTemp.Replace(_T("\n"), _T("\r\n"));
\r
61 toolTextMap[::GetDlgCtrlID(pWnd->GetSafeHwnd())] = sTemp;
\r
62 return CToolTipCtrl::AddTool(pWnd, LPSTR_TEXTCALLBACK, lpRectTool, nIDTool);
\r
65 BOOL CToolTips::AddTool(CWnd* pWnd, LPCTSTR lpszText /* = LPSTR_TEXTCALLBACK */, LPCRECT lpRectTool /* = NULL */, UINT_PTR nIDTool /* = 0 */)
\r
67 if (lpszText != LPSTR_TEXTCALLBACK)
\r
68 toolTextMap[::GetDlgCtrlID(pWnd->GetSafeHwnd())] = CString(lpszText);
\r
69 return CToolTipCtrl::AddTool(pWnd, lpszText, lpRectTool, nIDTool);
\r
72 void CToolTips::AddTool(int nIdWnd, UINT nIdText, LPCRECT lpRectTool /* = NULL */, UINT_PTR nIDTool /* = 0 */)
\r
74 AddTool(((CDialog*)m_pParentWnd)->GetDlgItem(nIdWnd), nIdText, lpRectTool, nIDTool);
\r
77 void CToolTips::AddTool(int nIdWnd, CString sBalloonTipText, LPCRECT lpRectTool /* = NULL */, UINT_PTR nIDTool /* = 0 */)
\r
79 AddTool(((CDialog*)m_pParentWnd)->GetDlgItem(nIdWnd), sBalloonTipText, lpRectTool, nIDTool);
\r