Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Render Taskbar Button

Posted on 2009-05-04
12
Medium Priority
?
610 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

722 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