2

In writing a custom control inheriting from a TBitBtn, I'm searching for a way to override or intercept just the drawing of the glyph and draw the glyph myself, while not having to redraw the entire control. I'm widely using VCL Styles and am looking to avoid having to recreate all the drawing and style hooks etc. Unfortunately I can't find anything inside the TBitBtn which could allow this.

How can I intercept the drawing of the TBitBtn.Glyph and draw the glyph onto the button canvas myself while retaining all the natural styled drawing of the control?

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
  • 3
    I would "re-introduce" a new `Glyph` property , and override the `CNDrawItem` which actually calls `DrawItem`. after you inherited `CNDrawItem`, draw your own `Glyph`. – kobik Feb 04 '15 at 17:04

1 Answers1

3

The TBitBtn control uses the TButtonGlyph class to draw the glyph, unfortunately none of the methods related to the draw (TButtonGlyph.DrawButtonGlyph, TButtonGlyph.Draw) are marked as virtual. So in order to only change the way of how draw the glyph you can patch the TButtonGlyph.DrawButtonGlyph or the ButtonGlyph.Draw procedure using a detour.

RRUZ
  • 134,889
  • 20
  • 356
  • 483