Draw ToolbarButton Image

  • Thread starter Thread starter Tom
  • Start date Start date
T

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
 
Hi,

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

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

Ken
 
* "Ken Tucker said:
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 ;-).
 
* "Ken Tucker said:
... 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
 
Back
Top