michael2705
asked on
Render Taskbar Button
Hi All,
I try to make an AppBar and I'd like to have some Buttons on it.
So far, everthing is ok. But I try to give my buttons the style of the taskbar buttons. Same background, same mouse over effect, same everything...
I tried using VisualStyleRenderer but no luck.
Any ideas?
Thanks
I try to make an AppBar and I'd like to have some Buttons on it.
So far, everthing is ok. But I try to give my buttons the style of the taskbar buttons. Same background, same mouse over effect, same everything...
I tried using VisualStyleRenderer but no luck.
Any ideas?
Thanks
Your application don't work on XP OS?
I think you should check VisualStyles is enabled or not on selected theme.
Check out this link:
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic37106.aspx
Hope this helps
Check out this link:
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic37106.aspx
Hope this helps
ASKER
Thanks so far. Maybe you missunderstood me. I know how to use the VisualStyleRenderer but I just can't find the TaskBarButtonBackground and Edges in the list of the VisualStyleElements.
for back ground, you can use sub-class of VisualStyleElement.Taskbar including: BackgroundTop, BackgroundBottom, BackgroundLeft and BackgroundRight.
For Edges you can use DrawEdge method (VisualStyleRenderer.DrawE dge return Rectangle)
For Edges you can use DrawEdge method (VisualStyleRenderer.DrawE
ASKER
Sounds good, but I can't follow you.
On Vista, for example, the buttons have rounded edges...
I just post what I've got so far.
On Vista, for example, the buttons have rounded edges...
I just post what I've got so far.
class MyButton : Button
{
public MyButton()
: base()
{
}
protected override void OnPaint(PaintEventArgs pevent)
{
VisualStyleElement el = VisualStyleElement.Taskbar.BackgroundBottom.Normal;
VisualStyleRenderer r = new VisualStyleRenderer(el);
r.DrawBackground(pevent.Graphics, this.ClientRectangle);
r.DrawEdge(pevent.Graphics, this.ClientRectangle, Edges.Left, EdgeStyle.Etched, EdgeEffects.None);
r.DrawEdge(pevent.Graphics, this.ClientRectangle, Edges.Top, EdgeStyle.Etched, EdgeEffects.None);
r.DrawEdge(pevent.Graphics, this.ClientRectangle, Edges.Right, EdgeStyle.Etched, EdgeEffects.None);
r.DrawEdge(pevent.Graphics, this.ClientRectangle, Edges.Bottom, EdgeStyle.Etched, EdgeEffects.None);
}
}
ASKER
Still no idea!
So actually if you want to draw round button, you must use GraphicsPath (System.Drawing.Drawing2D namespace) instead of using VisualStyleRenderer. There are a lot of sample, have a look.
http://www.xtremedotnettalk.com/showthread.php?t=77290
http://www.codeproject.com/KB/buttons/aquabutton.aspx
http://www.xtremedotnettalk.com/showthread.php?t=77290
http://www.codeproject.com/KB/buttons/aquabutton.aspx
ASKER
Thanks. But, that still doesn't help me to determine the current visual sytle of the taskBarButton.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Congratulation! :)
ASKER
Yea, finally! :-)
Thanks, anyways
Thanks, anyways
ASKER
...but it only works on Vista! Any ideas for XP?