Article View: comp.os.ms-windows.programmer.tools.mfc
Article #107Ugly code sample to detect mouse pointer being over a tray icon...
From: Peter Hirschberg
Date: Fri, 25 Sep 1998 00:00
Date: Fri, 25 Sep 1998 00:00
48 lines
1784 bytes
1784 bytes
Okay. In my continuing quest to create my own user-drawn tooltips
for a tray-icon, I've come up with this very ugly piece of code that
DOES WORK. It will successfully detect when the mouse pointer is over
the icon for a certain amount of time, and when it has left the icon.
...can anybody tell me WHY this works?!!!! :-P
peter
LRESULT CMainWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_CAPTURECHANGED){
if ((lParam != 0) && (tooltip)){
ttcount = 0;
tooltip = FALSE;
TRACE("TOOLTIP OFF!!!\n");
// <<<< remove the tooltip here >>>>
}
}
if (uMouseMsg == WM_MOUSEMOVE){
::SetCapture(this->m_hWnd);
KillTimer(ID_TT_TIMER);
SetTimer(ID_TT_TIMER, 100, NULL);
}
}
void CMainWindow::OnTimer(UINT nIDEvent)
{
if (nIDEvent == ID_TT_TIMER){
KillTimer(ID_TT_TIMER);
::ReleaseCapture();
if (!tooltip){
++ttcount;
}
if ((ttcount == 5) && (!tooltip)){
// <<<< produce the tooltip here >>>>
TRACE("TOOLTIP ON\n");
tooltip = TRUE;
}
}
}
Technical Details
Message-ID:
<6ugavk$ni9$1@callisto.clark.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 110a07,b53a880132bfd931,start X-Google-Attributes: gid110a07,public X-Google-Thread: 1138df,b53a880132bfd931,start X-Google-Attributes: gid1138df,public X-Google-Thread: 104d65,b53a880132bfd931,start X-Google-Attributes: gid104d65,public From: "Peter Hirschberg" <peterh@cronuscom.com> Subject: Ugly code sample to detect mouse pointer being over a tray icon... Date: 1998/09/25 Message-ID: <6ugavk$ni9$1@callisto.clark.net> X-Deja-AN: 394748832 Organization: Verio East X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: comp.os.ms-windows.programmer.tools.mfc,fj.os.ms-windows.programming,microsoft.public.vc.mfc