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.