Solved

Render Taskbar Button

Posted on 2009-05-04
12
564 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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

Suggested Solutions

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now