Solved

Render Taskbar Button

Posted on 2009-05-04
12
560 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

8 Experts available now in Live!

Get 1:1 Help Now