Bonjour,
je vous expose mon souci :

je veux afficher un tooltip poour chaque ligne d'un CListCtrl. Mon problème : le tooltip s'affiche les 2 à 3 première fois et très brievement, puis plus rien.
Je dois loupé un truc !


voici mon code (partiel) : j'ai repris un code que j'ai trouvé sur le net. Testé en dehors de mon projet, il fonctionne bien. Maintenant la CToolTipCtrl est intégré dans une CDialogBox redéfinie dont je n'ai pas le code (çà c'est une obligation de mon pj). Je ne sais pas si çà peut venir de çà.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
 
int CToolTipListCtrl::OnToolHitTest(CPoint point, TOOLINFO * pTI) const {
... (jamais appelée donc je ne précise pas le code)
}
 
BOOL CToolTipListCtrl::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ){
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
   *pResult = 0;
	CString strTipText;
 
	//Get the mouse position
	const MSG* pMessage;
    pMessage = GetCurrentMessage();
	ASSERT ( pMessage );
    CPoint pt;
    pt = pMessage->pt; //Get the point from the message
	ScreenToClient( &pt ); //Convert the point's coords to be relative to this control
 
	LVHITTESTINFO lvhitTestInfo;
 
	lvhitTestInfo.pt	= pt;
 
	int nItem = SubItemHitTest(&lvhitTestInfo);
	int nSubItem = lvhitTestInfo.iSubItem;
 
	UINT nFlags =   lvhitTestInfo.flags;
 
   if( nFlags & m_wHitMask ){
	  CString strKey;
 
	  strKey.Format(_T("%d"),  nItem * 100 + nSubItem);
 
      if( m_ToolTipMap.Lookup(strKey, strTipText ) ){
          _mbstowcsz(pTTTW->szText, strTipText, 80);
         return FALSE;			
      }
   }
 
   return FALSE; //We didn't handle the message,
                 //let the framework continue propagating the message
}
Je pense que le fais que ma fonction OnToolHitTest ne soit pas appelée peut être une piste pour touver mon problème !

Qu'en pensez vous ?

Merci d'avance pour vos conseils et avis