1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
8 // This program is free software; you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by the Free
10 // Software Foundation; either version 2 of the License, or (at your option)
13 // This program is distributed in the hope that it will be useful, but WITHOUT
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
25 // ttlistctrl.cpp : implementation file
29 #include "ttlistctrl.h"
34 static char THIS_FILE[] = __FILE__;
37 /////////////////////////////////////////////////////////////////////////////
40 CTTListCtrl::CTTListCtrl()
44 CTTListCtrl::~CTTListCtrl()
49 BEGIN_MESSAGE_MAP(CTTListCtrl, CListCtrl)
50 //{{AFX_MSG_MAP(CTTListCtrl)
52 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
53 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
56 /////////////////////////////////////////////////////////////////////////////
57 // CTTListCtrl message handlers
59 int CTTListCtrl::OnToolHitTest(CPoint point, TOOLINFO * pTI) const
61 CTTListCtrl &l=(CTTListCtrl &)*this;
64 if(-1!=l.SubItemHitTest(&info)){
66 l.GetSubItemRect(info.iItem,info.iSubItem,LVIR_LABEL,rect);
69 CFont *pOldFont=pDC->SelectObject(GetFont());
70 int cx=pDC->GetTextExtent(GetItemText(info.iItem,info.iSubItem)).cx;
71 pDC->SelectObject(pOldFont);
73 if(cx>GetColumnWidth(info.iSubItem)-10){
76 pTI->uId = 1+MAKELONG(info.iItem,info.iSubItem);
77 pTI->lpszText = LPSTR_TEXTCALLBACK;
86 BOOL CTTListCtrl::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
88 // need to handle both ANSI and UNICODE versions of the message
89 TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
90 TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
93 if(0==id--){ // Notification in NT from automatically
94 return FALSE; // created tooltip
96 const CString strTipText(GetItemText(LOWORD(id),HIWORD(id)));
98 if (pNMHDR->code == TTN_NEEDTEXTA)
99 lstrcpyn(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1);
101 _mbstowcsz(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1);
103 if (pNMHDR->code == TTN_NEEDTEXTA)
104 _wcstombsz(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1);
106 lstrcpyn(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1);
109 GetSubItemRect(LOWORD(id),HIWORD(id),LVIR_LABEL,rect);
110 ClientToScreen(rect);
111 //::SetWindowPos(pNMHDR->hwndFrom,NULL,rect.left,rect.top,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSENDCHANGING);
114 return TRUE; // message was handled
118 void CTTListCtrl::PreSubclassWindow()
120 CListCtrl::PreSubclassWindow();
121 EnableToolTips(TRUE);