Fenetre jaune

cs_Xs Messages postés 368 Date d'inscription mercredi 14 novembre 2001 Statut Membre Dernière intervention 1 septembre 2008 - 3 juin 2002 à 21:04
TheRod23 Messages postés 69 Date d'inscription dimanche 15 octobre 2000 Statut Membre Dernière intervention 15 mars 2004 - 4 juin 2002 à 10:07
Salut !

j'ai beau chercher dans toutes les API que je connaisse ou pas, je ne trouve comment faire pour lorsque,
la souris reste un certain temps sur un objet de ma list-box, une fenetre de survol (vous savez, celles
qui sont en jaune et qui donnes des infos), eh bien, s'affiche.

attention, si deja vous me dites comment faire pour afficher cette "fenetre", je serais deja trs content.

et puis ca suffirai seulement puisque en même temps que je voyus ecris ca, j'ai trouvé la solution pour
le temps (TIMER)...

donc, je réitere ma question : commen afficher une "fenetre" jaune ?

****************************
Le C/C++ et une Veritable merveille !
****************************

1 réponse

TheRod23 Messages postés 69 Date d'inscription dimanche 15 octobre 2000 Statut Membre Dernière intervention 15 mars 2004
4 juin 2002 à 10:07
Salut,

voila la solus si tu fonctionne sous visual

rajoute ses deux lignes dans la message map

ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)

comme suit

BEGIN_MESSAGE_MAP(CToolTipListCtrl, CListCtrl)
//{{AFX_MSG_MAP(CToolTipListCtrl)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP

//Trap all TTN_NEEDTEXT* Messages
//TTN_NEEDTEXT* messages are sent when a ToolTipCtrl wants a control
//to provide it with text to display as the tooltip.
//Specifically, when the TOOLINFO structure passed back to the ToolTipCtrl
//after ::OnToolHitTest has it's lpszText memeber set to LPSTR_TEXTCALLBACK.

ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
END_MESSAGE_MAP()

et ensuite implement la fonction OnToolTipText
cet exemple recupere dans une liste report l'indice de colone et de ligne ou se situe la sourie et te l'affiche

BOOL CToolTipListCtrl::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult ){
//Handle both ANSI and UNICODE versions of the message
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;

//Ignore messages from the built in tooltip, we are processing them internally
if( (pNMHDR->idFrom == (UINT)m_hWnd) &&
( ((pNMHDR->code == TTN_NEEDTEXTA) && (pTTTA->uFlags & TTF_IDISHWND)) ||
((pNMHDR->code == TTN_NEEDTEXTW) && (pTTTW->uFlags & TTF_IDISHWND)) ) ){
return FALSE;
}

*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

//See if the point falls onto a list item

LVHITTESTINFO lvhitTestInfo;

lvhitTestInfo.pt = pt;

int nItem = SubItemHitTest(&lvhitTestInfo);
int nSubItem = lvhitTestInfo.iSubItem;

UINT nFlags = lvhitTestInfo.flags;

//nFlags is 0 if the SubItemHitTest fails
//Therefore, 0 & will equal false
if( nFlags & m_wHitMask ){
//If it did fall on a list item,
//and it was also hit one of the
//item specific sub-areas we wish to show tool tips for

//Lookup the list item's text in the ToolTip Map

CString strKey;

strKey.Format(_T("%d"), nItem * 100 + nSubItem);

if( m_ToolTipMap.Lookup(strKey, strTipText ) ){
//If there was a CString associated with the list item,
//copy it's text (up to 80 characters worth, limitation of the TOOLTIPTEXT structure)
//into the TOOLTIPTEXT structure's szText member

//Deal with UNICODE
#ifndef _UNICODE
if (pNMHDR->code == TTN_NEEDTEXTA)
lstrcpyn(pTTTA->szText, strTipText, 80);
else
_mbstowcsz(pTTTW->szText, strTipText, 80);
#else
if (pNMHDR->code == TTN_NEEDTEXTA)
_wcstombsz(pTTTA->szText, strTipText, 80);
else
lstrcpyn(pTTTW->szText, strTipText, 80);
#endif
return FALSE; //We found a tool tip,
//tell the framework this message has been handled

////////////////////////////////////////////////////////////////////////////////
// ****** Special note *****
//
// Still don't understand why the function must return FALSE for CListCtrl
// so as not to cause flickering, as opposed to Nate Maynard's derivation
// from CTreeCtrl.
// I have experimented with disabling Tooltips for the control
// and found out that a "ghost" tooltip appears for a fraction of a second...
//
// I am completely at a loss...
// Seems to work, though...
//
////////////////////////////////////////////////////////////////////////////////

}
}

bon courage
@+
TheRod23
0
Rejoignez-nous