This is a strange thing I'm doing, but how can I set the title of a winform form in the taskbar, but not in its titlebar?
-
2Just out of curiosity, why are you doing it? – Unmesh Kondolikar Mar 09 '11 at 12:07
-
Why the nic *Lucifer*? It's amazing how people want to be referred with Hell. – Buhake Sindi Mar 09 '11 at 12:08
-
@Unmesh Kondolikar; I am doing it this way so I can do custom drawing on the titlebar of my form, but i still want the title to be displayed on the taskbar. – Mar 09 '11 at 12:15
-
@The Elite Gentleman; I'm all for god and heaven and stuff, but I want to go to hell. I don't want to be anywhere near a creator who gave humans free will. If we were all 'programmed' (not given free will) to be good, my life wouldn't be so **** right now. :-) – Mar 09 '11 at 12:17
-
1Don't they teach such mischief in Hell? [= – Saeb Amini Mar 09 '11 at 12:18
-
@Saeb Amini; I'm not sure I completely understand, sorry :( What you mean? – Mar 09 '11 at 12:20
-
2@Lucifer, I don't think you want to go to hell. I just wish you could see the creator himself and ask him about the issues you have. Wait, you can! – Buhake Sindi Mar 09 '11 at 12:42
-
@Everyone; A thought just occured (uncommon :P) - This is exactly what Microsoft has done with Windows Explorer! They don't have a title in the Windows Explorer folder window, but when you hover over its icon in the Taskbar (Vista and 7), it will show the current-open folder name! I think I may have a solution, please see my answer if you're interested. It's not a proper way, but it's a workaround, until I can make a proper solution. – Mar 09 '11 at 12:44
-
Just because MS does something annoying in one of their programs doesn't mean you should do that too. – CodesInChaos Mar 09 '11 at 12:47
-
@CodeInChaos; I agree. At first, when I bought Windows 7 Home Premium, I hated the fact that Windows Explorer never showed a title in the titlebar, and I even googled "How to display title in windows explorer titlebar" and "Registry entries to set title for windows explorer titlebar", but found nothing. But, as time went on, I got used to it, and now I kinda like it, it's very simplistic, and What I am doing in my app is drawing my logo up there (where the title usually is). It's just a personal project which will only be used by myself anyway. :) – Mar 09 '11 at 12:51
4 Answers
A possible solution (it works fine for me) it's to override the CreateParams property and set the caption to be displayed in the taskbar:
protected override CreateParams CreateParams
{
get
{
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
// Extend the CreateParams property of the Button class.
CreateParams cp = base.CreateParams;
// Update the button Style.
cp.Style &= ~0xC00000; //WS_CAPTION;
cp.Caption = PRODUCT_NAME;
return cp;
}
}
I hope that works for you,
Lisa

- 61
- 1
- 2
Okay, so my temporary work around is this:
At runtime/design-time, Clear the Text Property for the Form (Form1, or whatever form this applies to), and when the Minimize, or Hide() events are triggered, change the Text Property to display a Title. So, when the form is hidden or minimized, you won't be able to see the titlebar anyway, but you will be able to see the caption on the Taskbar! And when the Form is later maximized, or when the Form.WindowState == WindowState.Normal, then clear the Text Property again. :-)
I wonder if this is the approach MS took!?
Edit:
Okay, sweet, I've got some working code of yumminess:
If you're using Visual Studio, go to Design View, select the Form control, open the Properties Pane, click the Events Tab, then double-click the Resize event. The Code View should display. Inside the Resize() code that was just created, type this:
private void Form_Resize( object sender, System.EventArgs e )
{
if( this.WindowState == FormWindowState.Minimized )
this.Text "Some uber-awesome title.";
}
Step 2: When you want to show/maximize the form again, simply edit the above so it looks like this:
private void Form_Resize( object sender, System.EventArgs e )
{
if( this.WindowState == FormWindowState.Minimized )
this.Text "Some uber-awesome title.";
else if(this.WindowState == FormWindowState.Normal || this.WindowState == FormWindowState.Maximized)
{
this.Text = String.Empty; // Or, you can use: this.Text = "";
}
}
However, this does not completely solve my problem yet. It still doesn't display the Title in the Taskbar when the Form is Visible to the user (because the Text property of the Titlebar is empty.
A workaround could be drawing your own form title bar. That way you won't need to change the actual title that's shown in Taskbar.

- 23,054
- 9
- 78
- 76
-
Hmmm, interesting. I'll give it a shot if I can't find an easier solution (I'm not very good at the drawing part, especially when there's the aero glass involved) - but thanks for your answer, I'll keep it in mind :) – Mar 09 '11 at 12:23
-
I just saw your site :), do you provide development/design service to Australia? Or is it only a local thing? – Mar 09 '11 at 12:30
-
@Lucifer: I do in fact [= Most of my clients are from across the world and I've had a few from Australia. – Saeb Amini Mar 09 '11 at 12:35
-
This question is about WPF rather than Winforms but it's applicable: Set a taskbar text different from the Window title in wpf