The. net call to refresh the tray area code in the win11 system does not take effect when clearing residual icons

Xia Xia1 Kang 0 Reputation points
2023-06-02T04:01:01.6866667+00:00

The relevant code for refreshing the tray area is called in the win11 system code, and it does not take effect occasionally

The residual icon still exists, it can disappear when the mouse hovers over it

The code is as follows:

const uint WM_MOUSEMOVE = 0x0200;
                bool isSuccess = GetClientRect(windowHandle, out Rect rect);
                LogsHelper.Instance.DebugWrite($"isSuccess:{isSuccess} GetClientRect right:{rect.right}  bottom:{rect.bottom}");
                if (rect.right == 0)
                {
                    rect.right = 320;
                }
                if (rect.bottom == 0)
                {
                    rect.bottom = 320;
                    LogsHelper.Instance.DebugWrite("rect.bottom = 320");
                }
                for (int x = 0; x < rect.right; x += 5) 
                {
                    for (int y = 0; y < rect.bottom; y += 5) 
                    {
                        SendMessage(windowHandle, WM_MOUSEMOVE, 0, (y << 16) + x); 
                    }
                }
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,608 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,511 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,903 questions
Microsoft Managed Desktop
Microsoft Managed Desktop
A cloud-based service that brings together Microsoft 365 Enterprise and adds these features: User device deployment; IT service management and operations; and Security monitoring and response.
48 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more