BOOL CXTTipWindowNotify::ShowTipWindow(const CPoint& point, DWORD dwTipStyle, UINT nDelay, UINT nElapse, BOOL bCenterHorz) { BOOL bRetVal = CXTTipWindow::ShowTipWindow(point, dwTipStyle, nDelay, nElapse, bCenterHorz);
if (bRetVal) { CRect rc; CRect rc2; CPoint pt; GetCursorPos(&pt); HMONITOR hMon = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); MONITORINFO monInfo; bool bChanged = false;
monInfo.cbSize = sizeof(monInfo); if (hMon && GetMonitorInfo(hMon, &monInfo)) { rc = monInfo.rcMonitor; } else { // can't get mon info, just use desktop ::GetClientRect(::GetDesktopWindow(), &rc); }
InitializeSize(m_ptMousePos, m_bCenterHorz); //Calculates m_rcScreenWindow values rc2 = m_rcScreenWindow;
if (rc2.left < rc.left) { // move right int nDelta = rc.left - rc2.left; m_ptMousePos.x += nDelta; m_rectTipArea.right -= nDelta; bChanged = true; } else if (rc2.right > rc.right) { // move left int nDelta = rc2.right - rc.right; m_ptMousePos.x -= nDelta; m_rectTipArea.left += nDelta;
// this is needed to make the tooltip hide as soon as you cross over the monitor boundary if (m_rectTipArea.right+m_ptMousePos.x > rc.right) m_rectTipArea.right = rc.right - m_ptMousePos.x; bChanged = true; }
if (!nDelay && bChanged) { // lets move the tip it is already displayed InitializeSize(m_ptMousePos, m_bCenterHorz); //Calculates m_rcScreenWindow values SetWindowPos(&wndTop, m_rcScreenWindow.left, m_rcScreenWindow.top, m_rcScreenWindow.Width(), m_rcScreenWindow.Height(), SWP_SHOWWINDOW|SWP_NOACTIVATE); } } return bRetVal; }
|