OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [common/] [win32/] [TTListCtrl.cpp] - Blame information for rev 790

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
// ttlistctrl.cpp : implementation file
23
//
24
 
25
#include "stdafx.h"
26
#include "ttlistctrl.h"
27
 
28
#ifdef _DEBUG
29
#define new DEBUG_NEW
30
#undef THIS_FILE
31
static char THIS_FILE[] = __FILE__;
32
#endif
33
 
34
/////////////////////////////////////////////////////////////////////////////
35
// CTTListCtrl
36
 
37
CTTListCtrl::CTTListCtrl()
38
{
39
}
40
 
41
CTTListCtrl::~CTTListCtrl()
42
{
43
}
44
 
45
 
46
BEGIN_MESSAGE_MAP(CTTListCtrl, CListCtrl)
47
        //{{AFX_MSG_MAP(CTTListCtrl)
48
        //}}AFX_MSG_MAP
49
  ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
50
        ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
51
END_MESSAGE_MAP()
52
 
53
/////////////////////////////////////////////////////////////////////////////
54
// CTTListCtrl message handlers
55
 
56
int CTTListCtrl::OnToolHitTest(CPoint point, TOOLINFO * pTI) const
57
{
58
  CTTListCtrl &l=(CTTListCtrl &)*this;
59
  LVHITTESTINFO info;
60
  info.pt=point;
61
  if(-1!=l.SubItemHitTest(&info)){
62
    CRect rect;
63
    l.GetSubItemRect(info.iItem,info.iSubItem,LVIR_LABEL,rect);
64
 
65
    CDC *pDC=l.GetDC();
66
    CFont *pOldFont=pDC->SelectObject(GetFont());
67
    int cx=pDC->GetTextExtent(GetItemText(info.iItem,info.iSubItem)).cx;
68
    pDC->SelectObject(pOldFont);
69
    l.ReleaseDC(pDC);
70
    if(cx>GetColumnWidth(info.iSubItem)-10){
71
 
72
      pTI->hwnd = m_hWnd;
73
            pTI->uId = 1+MAKELONG(info.iItem,info.iSubItem);
74
            pTI->lpszText = LPSTR_TEXTCALLBACK;
75
            pTI->rect = rect;
76
 
77
            return pTI->uId;
78
    }
79
  }
80
  return -1;
81
}
82
 
83
BOOL CTTListCtrl::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
84
{
85
        // need to handle both ANSI and UNICODE versions of the message
86
        TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
87
        TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
88
        id=pNMHDR->idFrom;
89
 
90
  if(0==id--){           // Notification in NT from automatically
91
                return FALSE;           // created tooltip
92
  } else {
93
          const CString strTipText(GetItemText(LOWORD(id),HIWORD(id)));
94
#ifndef _UNICODE
95
          if (pNMHDR->code == TTN_NEEDTEXTA)
96
                  lstrcpyn(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1);
97
          else
98
                  _mbstowcsz(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1);
99
#else
100
          if (pNMHDR->code == TTN_NEEDTEXTA)
101
                  _wcstombsz(pTTTA->szText, strTipText, sizeof pTTTA->szText/sizeof TCHAR - 1);
102
          else
103
                  lstrcpyn(pTTTW->szText, strTipText, sizeof pTTTW->szText/sizeof TCHAR - 1);
104
#endif
105
    CRect rect;
106
    GetSubItemRect(LOWORD(id),HIWORD(id),LVIR_LABEL,rect);
107
    ClientToScreen(rect);
108
    //::SetWindowPos(pNMHDR->hwndFrom,NULL,rect.left,rect.top,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOSENDCHANGING);
109
    *pResult = 0;
110
 
111
          return TRUE;    // message was handled
112
  }
113
}
114
 
115
void CTTListCtrl::PreSubclassWindow()
116
{
117
        CListCtrl::PreSubclassWindow();
118
  EnableToolTips(TRUE);
119
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.