Reputation: 1983
I have a top level (ie. acts like a window) UserControl
(.NET 4.0) which I am using to simulate a custom form. I can easily set the title text and taskbar text like so:
public override string Text
{
get { return base.Text; }
set
{
base.Text = value
TitleText.Text = value;
}
}
Which sets both the title text and taskbar text:
Please note that the bar down the bottom of the image is my actual taskbar; I have installed an alternate shell
UserControl
as it has no overridable Icon
property so I can't set the taskbar icon as I would with the text. Please also note that the icon shown in the UserControl
is just a PictureBox
containing an image.
But I can't do this as there is no Icon
property for a UserControl
:
public override Icon Icon
{
get { return base.Icon; }
set
{
base.Icon = value;
TitleBarIcon.Image = value.ToBitmap();
}
}
Upvotes: 1
Views: 669
Reputation: 1377
I am not sure if I got you right but I think you have to possibilites:
Either set the Icon of the ParentForm.
Or set the ApplicationIcon as described here: http://msdn.microsoft.com/en-us/library/339stzf7.aspx
EDIT:
As you are using a control as TopLevelControl you need to send the WM_SETICON during the creation of the control - as the form does!
Taken from the Form.CreateHandle:
Icon icon = this.Icon;
if (icon != null && this.TaskbarOwner.Handle != IntPtr.Zero)
{
UnsafeNativeMethods.SendMessage(this.TaskbarOwner, 128, 1, icon.Handle);
}
Upvotes: 1