Question

I don't want to FORCE it to be visible, I just want it to check to see if it is hidden by Windows.

Windows by default, hides the trayicons other than the system icons (Action Center, Battery, Network, Sound, Date and Time).

enter image description here

Was it helpful?

Solution 2

@Hans says there's no direct way to find out, which is unfortunate (but makes sense).

You can still try to find out indirectly. You can take a snapshot of the desktop bitmap, find the task-bar (I think that in Windows 7 it can't be moved from the bottom, I'm not sure) and look for your icon. If you find it - it's there.

OTHER TIPS

I use the function Shell_NotifyIconGetRect, and get return value to check if NotifyIcon is hidden.

When the NotifyIcon is not hidden (in visible Tray part) , the function will return zero. When the NotifyIcon is hidden, the function will return 0x00000001 that means Incorrect function. It is really hack, and I don't know why. here is an example:

bool isIconHidden = false;
int hresult = Shell_NotifyIconGetRect(ref nid, out rect);

if (hresult == 0)
{
    isIconHidden = false;
}
else if (hresult == 0x00000001)
{
    isIconHidden = true;
}
else
    throw new Win32Exception(hresult);

The more detail about Shell_NotifyIconGetRect function usage, please see Notify Icon Position and Determining location of tray icon. But I'm not sure the solution is available on all Windows platforms. My OS is Win10 Family. hope it works for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top