Windows Develop Bookmark and Share   
 index > Windows Forms General > C# - how to display taskbar icon for borderless form?
 

C# - how to display taskbar icon for borderless form?

I have a borderless form in C#.
The form has an icon specified in its properties and I also have the same icon specified for the project in the project properties.
When I had a border on the form, the icon was displayed in the task bar. But when I set the border to None, the icon no longer displays. The taskbar button only shows the text name of my program.

How can I get the icon to display in the taskbar for a borderless form?

Thanks.
plevintampabay  Saturday, January 05, 2008 4:40 AM
Problem solved.

The problem was my ico file. I only had a 32x32 (true color + alpha) image in the ico file. This worked fine on all OS's (Win2K, XP and Vista) so long as I had a border on the form. But when I went to no border, it did not work for Win2K and Vista.

I created an ico file with 16x16, 32x32, 48x48, and 256x256, all true color + alpha. Now I have the icon in the taskbar button on all OS's (for the no border form). I could not tell you which of the icon images is being used where, but I don't care. They were simple enough to create and the problem is solved.

Along with the bit of code obtained from the link given by "marcel nita" (see post above), I now have a borderless form with a taskbar button that has the icon and menu.

Thanks for your help "marcel nita".

Paul

plevintampabay  Monday, January 07, 2008 4:17 AM
Set its ShowInTaskbar property to true.

Note that in this case the form won't have a system menu.

Regards.
Marcel Nita  Saturday, January 05, 2008 11:05 PM

Thank you for the reply. Howeveryour post does not help.

That property is already set to true.

Like I said in my original post, if the form has a border, the taskbar shows the icon. Change the border setting to none and the taskbar no longer shows the icon. It still shows the taskbar button, but without the icon.

plevintampabay  Sunday, January 06, 2008 2:27 AM
I really don't think it is possible...
What about adding a system tray entry for your applicaiton. That would definitely show your app's icon and you could also add some kind of system menu.
Marcel Nita  Sunday, January 06, 2008 2:30 AM
I have researched this problem extensively on the web. I have not found any solutions being offered. True, I have not found many people posting the same problem, but those that have, there has not been a single solution offered. Only the alternative that you suggested.

I may have to go that way (using the system tray), but frankly it is a bug in .NET. I run other programs that do not have a border and yet can show a taskbar button with an icon (and a menu).

plevintampabay  Sunday, January 06, 2008 2:39 AM
I think there might be a solution. Read the first post in this thread: http://www.msdner.com/dev-archive/180/2-8-1806474.shtm

It suggests to leave the form with a title bar, and remove it afterwards, by modifying its createparams.

Hope this helps.

Regards
Marcel Nita  Sunday, January 06, 2008 2:48 AM

Very interesting.
I gave that a try, and I still do not have an icon in the task bar button, but I do have the pop up menu there. So I'll use this bit of code.

Regarding the icon problem, I discovered that it is OS specific. On Windows 2000, I do not get an icon for the borderless form. On XP, I do get the correct icon. On Vista, I get an icon, but it does not look correct (as it does on XP). However, even with a border, the icon does not look correct on Vista, so that may not be relevant. Since it works on XP, which is my target environment, I may have to just accept that it does not work on Win 2K, which is my development machine.

Thanks for all your help. If you find any other relevant solutions/work arounds, I would love to see them. It would be nice for it to work on all OS's.

plevintampabay  Sunday, January 06, 2008 9:10 PM
Problem solved.

The problem was my ico file. I only had a 32x32 (true color + alpha) image in the ico file. This worked fine on all OS's (Win2K, XP and Vista) so long as I had a border on the form. But when I went to no border, it did not work for Win2K and Vista.

I created an ico file with 16x16, 32x32, 48x48, and 256x256, all true color + alpha. Now I have the icon in the taskbar button on all OS's (for the no border form). I could not tell you which of the icon images is being used where, but I don't care. They were simple enough to create and the problem is solved.

Along with the bit of code obtained from the link given by "marcel nita" (see post above), I now have a borderless form with a taskbar button that has the icon and menu.

Thanks for your help "marcel nita".

Paul

plevintampabay  Monday, January 07, 2008 4:17 AM

You can use google to search for other answers

Custom Search

More Threads

• P/Invoke on SendInput question ?
• datagridview default column width
• Weird Threading Problem
• Append Array of objects in Datagridview
• Header and Footer in Web page print
• plug to check spilling mistake the commnt in Source Code project
• Problem with Adding the WebBrowser tool
• How to implement a 30 day trial period?
• Complex dividing interface
• Set question