Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First time set Form.Text in Load event will cause no taskbar icon when program startup without focus #9770

Open
ahdung opened this issue Aug 23, 2023 · 8 comments
Labels
🪲 bug Product bug (most likely)
Milestone

Comments

@ahdung
Copy link

ahdung commented Aug 23, 2023

.NET version

.netfx2.0-.net6.0 tested, I believe it's ALL of .net versions.

Did it work in .NET Framework?

No

Did it work in any of the earlier releases of .NET Core or .NET 5+?

No response

Issue description

Meet follow conditions, .net winform app will no icon on taskbar:

  • Start without focus. for example, mouse clicks on other places during startup.
  • App set Form.Text is in Load event.
  • App not set Form.Text in constructor or InitializeComponent.

Steps to reproduce

NoTaskbarIconDemo.zip

  • Compiled exe included.
  • Note Text assignment in Form1.Designer.cs is commented.
  • Thread.Sleep in program.cs is for simulate production programs that need long startup time, so in this time it might happen many thing like lost focus, users usually don't wait only for you.
f9071f86-eb3b-4821-8f31-3e506392a68d.mp4
@ahdung ahdung added the untriaged The team needs to look at this issue in the next triage label Aug 23, 2023
@ahdung ahdung changed the title set Form.Text in Load event cause no taskbar icon when app starting without focus First time set Form.Text in Load event will cause no taskbar icon when program startup without focus Aug 23, 2023
@elachlan
Copy link
Contributor

elachlan commented Aug 23, 2023

https://stackoverflow.com/a/16343373

There are stack overflow posts from 2009 about it. I imagine the underlying window in the winapi requires the window have a name prior to creating it.

It also got reported via developer community:
https://developercommunity.visualstudio.com/t/setting-form-text-property-in-load-event-of-form-p/1566247

@ahdung
Copy link
Author

ahdung commented Aug 23, 2023

@elachlan Thank you, that can't explain why no issue when assignment in Shown event, and relate with focus.

@JeremyKuhne JeremyKuhne removed the untriaged The team needs to look at this issue in the next triage label Aug 24, 2023
@JeremyKuhne JeremyKuhne added this to the .NET 9.0 milestone Aug 24, 2023
@JeremyKuhne
Copy link
Member

@Olina-Zhang can you see if you can repro this on .NET 7 or 8? I wasn't successful in my initial attempts.

@Olina-Zhang
Copy link
Member

@Olina-Zhang can you see if you can repro this on .NET 7 or 8?

Yes, can also repro it on .NET7 and .NET8. Once launch application or exe, you should mouse click other place immediately with losing focus for winforms runtime. In that case, no taskbar icon of winforms runtime displays until it gets focus again.
Net8Behavior

@ahdung
Copy link
Author

ahdung commented Aug 29, 2023

@Olina-Zhang What's the screen record tool you using please?

@Olina-Zhang
Copy link
Member

@Olina-Zhang
Copy link
Member

@ahdung or use it from https://www.screentogif.com/ if you cannot access above link.

@ahdung
Copy link
Author

ahdung commented Aug 29, 2023

@Olina-Zhang Thank you very much.

@elachlan elachlan added the 🪲 bug Product bug (most likely) label Nov 4, 2023
@JeremyKuhne JeremyKuhne modified the milestones: .NET 9.0, Future Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Product bug (most likely)
Projects
None yet
Development

No branches or pull requests

4 participants