469,644 Members | 1,975 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,644 developers. It's quick & easy.

Draw ToolbarButton Image

Tom
Hi

Hi i am trying to draw on top of a button on a standard toolbar. All i
want to do is draw a small rectangle on the button to represent the
selected color.

I have tried the folowing code in the toolbar's parent control, which
is fired when the selected color is changed:

Dim r As Rectangle = FontColorButton.Rectangle
Dim g As Graphics = CreateGraphics()

g.FillRectangle(New SolidBrush(Color.Green), r)

This is not working, not really sure why, although i am pretty sure i
am approaching it from completely wrong angle.

Any help appreciated.

Thanks

Tom
Nov 20 '05 #1
3 1386
Hi,

Dim g As Graphics = ToolBar1.CreateGraphics
Dim r As Rectangle = ToolBarButton1.Rectangle

g.FillRectangle(New SolidBrush(Color.FromArgb(128, Color.Blue)), r)

Ken
-------------------------------
"Tom" <re***@to.group> wrote in message
news:mm********************************@4ax.com...
Hi

Hi i am trying to draw on top of a button on a standard toolbar. All i
want to do is draw a small rectangle on the button to represent the
selected color.

I have tried the folowing code in the toolbar's parent control, which
is fired when the selected color is changed:

Dim r As Rectangle = FontColorButton.Rectangle
Dim g As Graphics = CreateGraphics()

g.FillRectangle(New SolidBrush(Color.Green), r)

This is not working, not really sure why, although i am pretty sure i
am approaching it from completely wrong angle.

Any help appreciated.

Thanks

Tom

Nov 20 '05 #2
* "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit:
Dim g As Graphics = ToolBar1.CreateGraphics
Dim r As Rectangle = ToolBarButton1.Rectangle

g.FillRectangle(New SolidBrush(Color.FromArgb(128, Color.Blue)), r)


.... but don't forget to dispose the brush ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Tom
>* "Ken Tucker [MVP]" <vb***@bellsouth.net> scripsit:
Dim g As Graphics = ToolBar1.CreateGraphics
Dim r As Rectangle = ToolBarButton1.Rectangle

g.FillRectangle(New SolidBrush(Color.FromArgb(128, Color.Blue)), r)


... but don't forget to dispose the brush ;-).


Thanks guys, i actually went back a bit and decided what i should be
doing is modifying the image that is displayed on the toolbarbutton,
rather than the button it's self.

Cheers

Tom
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by DraguVaso | last post: by
1 post views Thread by R.Balaji | last post: by
2 posts views Thread by Peter Rilling | last post: by
5 posts views Thread by Barry Gast | last post: by
4 posts views Thread by Ahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.