Solved

Render Taskbar Button

Posted on 2009-05-04
12
576 Views
Last Modified: 2012-05-06
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
0
Comment
Question by:michael2705
  • 7
  • 5
12 Comments
 
LVL 13

Expert Comment

by:dungla
ID: 24353137
Your application don't work on XP OS?
0
 
LVL 13

Expert Comment

by:dungla
ID: 24353162
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
0
 

Author Comment

by:michael2705
ID: 24357206
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.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 13

Expert Comment

by:dungla
ID: 24360024
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.DrawEdge return Rectangle)
0
 

Author Comment

by:michael2705
ID: 24362183
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.
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);
        }
    }

Open in new window

0
 

Author Comment

by:michael2705
ID: 24378413
Still no idea!
0
 
LVL 13

Expert Comment

by:dungla
ID: 24380989
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
0
 

Author Comment

by:michael2705
ID: 24382204
Thanks. But, that still doesn't help me to determine the current visual sytle of the taskBarButton.
0
 

Accepted Solution

by:
michael2705 earned 0 total points
ID: 24616053
Got it! :-)

renderer.SetParameters("Taskband::Toolbar", VisualStyleElement.ToolBar.Button.Normal.Part, X);

Open in new window

0
 
LVL 13

Expert Comment

by:dungla
ID: 24618651
Congratulation! :)
0
 

Author Comment

by:michael2705
ID: 24621910
Yea, finally! :-)
Thanks, anyways
0
 

Author Comment

by:michael2705
ID: 24627327
...but it only works on Vista! Any ideas for XP?
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question