// -------------------------------------------------------------------------- void CToolTipWnd::OnTimer( UINT nIDEvent ) { if (nIDEvent == ID_TIMER_TOOLTIP_HIDE) { KillTimer(); KillShowTimer(); ShowWindow(SW_HIDE); } else if (nIDEvent == ID_TIMER_TOOLTIP_SHOW) { POINT pt; // Where is the mouse right now? if (GetCursorPos(&pt)) { // Over which window? CWnd* pWnd = WindowFromPoint(pt); // Save the relevant window handles TTWNDSTRUCT ws; ZeroMemory(&ws, sizeof(ws)); ws.hWndToolTip = GetSafeHwnd(); ws.hWndToolTipParent = pWnd->GetSafeHwnd(); // Now do the window handle comparisons EnumChildWindows(m_hParentWnd, EnumChildProc, (LPARAM)&ws); } } CWnd::OnTimer(nIDEvent); }
void CToolTipWnd::SetShowTimer( int iTimeTillShow ) { KillShowTimer( ); if ( iTimeTillShow > 0 ) // no timer if <= 0 m_iTimer2 = CWnd::SetTimer( ID_TIMER_TOOLTIP_SHOW, iTimeTillShow, 0 ); }
// -------------------------------------------------------------------------- void CToolTipWnd::Hide() { if ( IsWindowVisible() ) { ShowWindow( SW_HIDE ); KillTimer(); KillShowTimer(); } }
// -------------------------------------------------------------------------- CToolTipWnd::~CToolTipWnd() { if (m_iTimer > 0) KillTimer(); if (m_iTimer2 > 0) KillShowTimer(); // delete all BTOOLINFO entries put in the map BTOOLINFO* stToolInfo = NULL; HWND* pWnd; // dummy for (POSITION pos = m_toolPtr.GetStartPosition(); pos != NULL;) { m_toolPtr.GetNextAssoc(pos, (void *&)pWnd, (void *&)stToolInfo); delete stToolInfo; } m_toolPtr.RemoveAll(); }