Ditto icon indicating copy to clipboard operation
Ditto copied to clipboard

[BUG] ShowIconInSystemTray=0 didn't take effect as expected

Open weasonn opened this issue 6 months ago • 1 comments

Hi there,

I am using Windows 10 22H2 and the latest stable portable version of Ditto.

I noticed that even after adding the ShowIconInSystemTray=0 parameter, every time I start Ditto.exe, the tray icon is displayed for a while (10-30 seconds), and then the tray icon disappears.

When I asked the AI about SystemTray.cpp, it gave me the problem and it was due to a logic issue with the OnTaskbarCreated() and InstallIconPending() methods.

The solution was to modify the InstallIconPending() method to add the correct handling of hidden states:

void CSystemTray::InstallIconPending()
{
    // If the icon should be hidden, return it directly without recreating it.
    if (!m_bShowIconPending)
        return;
        
    // If the user explicitly sets it to be hidden, it should not be redisplayed either
    if (m_bHidden && !m_bShowIconPending)
        return;

    // Reset the flags to what was used at creation
    m_tnd.uFlags = m_uCreationFlags;

    // If it was hidden when it was originally created, keep it hidden
    if (m_uCreationFlags & NIF_STATE) {
        m_tnd.dwState = NIS_HIDDEN;
        m_tnd.dwStateMask = NIS_HIDDEN;
    }

    // Try and recreate the icon
    BOOL bResult = Shell_NotifyIcon(NIM_ADD, &m_tnd);
    m_bHidden = !bResult;
    m_bShowIconPending = !bResult;
}

I really like this clipboard tool and I hope you guys will make it better and better.

Thanks

weasonn avatar May 26 '25 09:05 weasonn

I'm in windows 11 25H2, and setting the registry or not setting the registry, or using the advanced editor, I can't make it show in the system tray.

jsreynolds avatar Oct 28 '25 22:10 jsreynolds