Solved

Render Taskbar Button

Posted on 2009-05-04
12
590 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Stressed Out?

Watch some penguins on the livecam!

 
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 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