Show custom tooltip windows on system tray icon

23 views
Skip to first unread message

LIANG ZHOU

unread,
Aug 23, 2021, 12:23:10 AM8/23/21
to wx-users
Hi, 
I need to show a custom tooltip window when mouse pointer hovers over the tray icon. 
This is how I implement this functionality.
void MyTaskBarIcon::OnMouseMove(wxTaskBarIconEvent& WXUNUSED(event))
{
    if (!m_bTrackMouse)
    {
        m_bTrackMouse = true;

        wxPoint ptMouse = wxGetMousePosition();
        int dpi = (int)getWinDPIMultiple();
        m_rectIcon.x = ptMouse.x - 25 * dpi;
        m_rectIcon.y = ptMouse.y - 25 * dpi;
        m_rectIcon.width = 50 * dpi;
        m_rectIcon.height = 50 * dpi;

        m_timer.Start(1000);
        m_pMainDlg->ShowToolTipDlg(ptMouse);
    }
}

void MyTaskBarIcon::OnTrackMouse(wxTimerEvent& WXUNUSED(event))
{
    wxPoint ptMouse = wxGetMousePosition();

    if (!m_rectIcon.Contains(ptMouse))
    {
        if (m_bTrackMouse)
        {
            m_bTrackMouse = false;
            m_timer.Stop();
            m_pMainDlg->HideToolTipDlg();
        }
    }
}

But when some new icon is created in the system tray, a wxEVT_TASKBAR_MOVE message would be sent, so my custom tooltip window would be shown unexpectedly. Is there any way to prevent this from happening? Thanks!

Leo



Igor Korot

unread,
Aug 23, 2021, 12:29:15 AM8/23/21
to wx-u...@googlegroups.com
Hi
I presume you are on Windows?
And using wx-3.1.4?

Thank you.

>
> Leo
>
>
>
> --
> Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
> ---
> You received this message because you are subscribed to the Google Groups "wx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/bb0b2560-03ef-46a2-87a0-8335e8c7736dn%40googlegroups.com.

LIANG ZHOU

unread,
Aug 23, 2021, 1:17:24 AM8/23/21
to wx-users
Hi,
I'm using wx-3.1.5 right now. 

Leo

Igor Korot

unread,
Aug 23, 2021, 1:33:39 AM8/23/21
to wx-u...@googlegroups.com
Hi

On Mon, Aug 23, 2021 at 12:17 AM LIANG ZHOU <zhouli...@gmail.com> wrote:
>
> Hi,
> I'm using wx-3.1.5 right now.

On Windows?

Thank you.
> To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/1583c71c-dfa6-4bde-95bb-03e1ff1932cbn%40googlegroups.com.

LIANG ZHOU

unread,
Aug 23, 2021, 6:02:09 AM8/23/21
to wx-users
Yes,my app runs on Windows.
Reply all
Reply to author
Forward
0 new messages