Share via

WinForms Form icon changes to EXE icon when positioned beside taskbar overflow (Windows 11)

test code 21 Reputation points
2026-02-25T07:17:28.41+00:00

In a VB.NET WinForms application (.NET Framework 4.0) running on Windows 11, a specific icon switching behavior occurs when the taskbar becomes crowded.

Here is my code snippet:

Public Class Form1
   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
   Try
    Me.Icon = New Icon("C:\Users\User1\source\repos\ForumSampleIcon\ForumSampleIcon\bin\Debug\Icons\resumelist.ico")
   Catch ex As Exception
    MsgBox(ex.Message)
   End Try
  End Sub
 End Class

I am using Me.Icon inside my form's load event to set my application icon which appears in the taskbar.

By default, Windows manages overflow by moving excess icons into a tray-like structure (the overflow menu). The issue arises when my form application icon is positioned next to the "three dots": the displayed taskbar icon switches from the specific Form icon to the executable (.exe) icon. Once the number of taskbar icons is reduced and the overflow tray disappears, the icon automatically reverts to the original Form icon.

Steps to reproduce:

  1. Create a Winforms application where the form icon is set in Form load event using Me.Icon as shown in the above code:
  2. In taskbar settings, change the "taskbar alignment" to Left and change "Combine taskbar buttons and hide labels" to Never
  3. Open many applications until the Windows 11 taskbar overflows
  4. Launch the WinForms application

Result:

If my application is moved inside the overflow area then there is no issue/error i.e form icon is visible. But if my application gets positioned next to overflow area i.e near three dots then the application icon gets changed to exe icon.
Expected behaviour:
If my application icon gets positioned next to the overflow area (i.e. near to three dots) in the taskbar, then the application icon must stay the same (i.e the form icon)

What I already checked:

I have tried using combination of setting Me.Icon & using SendMessage to set the icon inside Form's OnActivated event, toggling DPIAwareness to true/false and changing the icon to MS File Explorer (to verify if issue is with my icon's format) in the following order:

Form OnActivated event DPI Awareness MS File Explorer Icon Result
Using Me.Icon to set icon FALSE No Form icon is displayed in taskbar but it changes to exe icon when it is near three dots (...) during overflow.
Using Me.Icon to set icon FALSE Yes Form icon is displayed in taskbar but it changes to exe icon when it is near three dots (...) during overflow.
Using Me.Icon to set icon No Form icon is displayed in taskbar but it changes to exe icon when it is near three dots (...) during overflow.
Using Me.Icon to set icon Yes Form icon is displayed in taskbar but it changes to exe icon when it is near three dots (...) during overflow.
Using Me.Icon to set icon Cell 3 No Form icon is displayed in taskbar but it changes to exe icon when it is near three dots (...) during overflow. Question:

Why does this behaviour occur in Windows 11?
Screenshot:

FormIconissue

Posts already refered:

https://learn.microsoft.com/en-gb/answers/questions/2201775/windows-forms-application-icon-suddenly-shows-as-d

Developer technologies | Visual Basic for Applications
0 comments No comments

1 answer

Sort by: Most helpful
  1. Adiba Khan 2,345 Reputation points Microsoft External Staff
    2026-02-25T11:17:36.2533333+00:00

    Thank you for reaching out. This behavior is the known edge case in windows 11 where the shells taskbar rendering engine struggles to sink dynamically set icons (via Me.icon) with the overflow manager. When a WinForms application is pushed to the boundary of the “three dots” (…) overflow area the taskbar occasionally fails to pull the windows specific icon and instead falls back to the default icon embedded in the executables resource.

    The root cause

    the issue occurs because Me.Icon only changes the icon for that specific window instance. Windows 11 taskbar particularly when handling overflow frequently queries the process/executable level icon or the AppUserModelID cache. If the executable does not have a high resolution I can embed it at index 0 or if the OS has not cached the icon for that specific task bar slot it reverts to the generic “EXE” icon.

    Recommended solutions

    1. set the application level icon (primary fix) instead of relying solely on code to change the icon at runtime you must embed the icon into the project properties. This ensures that the window shell has a permanent reference to the icon even when the form is not fully “active” in the overflow calculations.
      1. In Visual Studio right click your project> properties
      2. go to application tab
      3. under resources locate the icon drop down and browse to your .ico file.
      4. Rebuild your solution this embeds the icon as resource ID 0 which is what the taskbar prefers.
    2. Implementation via Win32 API(if runtime changes are required) if you must set the icon via code(e.g., if the icon changes based on user state,) using Me.Icon is sometimes “too late” for the shell. You can use the send message API to explicitly tell the window shell to update both the small and big icons for the window handle.
         Imports System.Runtime.InteropServices
         
         Public Class Form1
         	<DllImport("user32.dll", CharSet:=CharSet.Auto)>
         	Private Shared Function
         	Send Message (ByVal hWnd As intPtr, ByVal Mg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
         	End function
         
         	Private Const WM_Seticon As integer = &H80
         	Private Const ICON_SMALL As integer = 0
         	Private Const Icon_BIG As Integer = 1
         	Private Sub Forml_Load(sender As Object, e As EventArgs) Handles MyBase.Load
         		Try
         			Dim newIcon As New Icon("C:\Path\To\Your\Icon.ico")
         			Me.Icon = newIcon
         		
         			' Force the Shell to recognise the new icon handles
         			SendMessage(Me.Handle, WM_SETICON, New IntPtr(ICON_SMALL),newIcon.Handle)
         			SendMessage(Me.Handle, WM_SETICON, New IntPtr(ICON_BIG),newIcon.Handle)
         		Catch ex As exception
         			MsgBox(ex.Message)
         		End Try
         	End Sub
         End Class
      
    3. Verification of icon formats windows 11 is stricter with DPI scaling. Ensure your .ico file contains the following sizes:
      1. 16x16, 24x24, 32x32, 48x48 and 256x256 (PMG compressed)
      If the 24x24 or 32x32 Sizes are missing the taskbar may fail to render the icon when it's being “shrunk” or move to near the overflow area.

     Please let us know if you require any further assistance we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer".


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.