Subject: Feature request: customizable glyph for cbGrayed state in TAdvOfficeCheckBox / TDBAdvOfficeCheckBox
Component: TAdvOfficeCheckBox (AdvOfficeButtons.pas) / TDBAdvOfficeCheckBox (DBAdvOfficeButtons.pas)
Current behavior:
When State = cbGrayed (e.g. triggered by a NULL field value in TDBAdvOfficeCheckBox.GetFieldState), DrawCheck (AdvOfficeButtons.pas, ~line 1376) renders the glyph via the native Windows theme API (DrawThemeBackground with CBS_MIXEDNORMAL/CBS_MIXEDHOT/CBS_MIXEDPRESSED/CBS_MIXEDDISABLED) when themed, or via the fixed embedded bitmap resources 'TMSOFCG'/'TMSOFCGH'/'TMSOFCGD' when not themed. In both cases the visual result is very close to the Unchecked state and is not distinguishable enough for end users, and there is currently no supported way to change or replace this glyph without editing the component source directly.
Requested enhancement — two possible approaches:
-
Design-time (Object Inspector): Extend the existing
Images/PictureContainerproperties so a custom image can be explicitly assigned per checkbox state — e.g.CheckedImageIndex,UncheckedImageIndex,GrayedImageIndex— so developers can supply their own glyph for the Grayed/indeterminate state through the Object Inspector, without any code. -
Runtime/code-level: Add an event or make the glyph-selection part of
DrawCheckoverridable, e.g.property OnGetCheckGlyph: TGetCheckGlyphEvent; // (Sender: TObject; State: TCheckBoxState; var Bitmap: TBitmap; var Handled: Boolean)or expose
DrawCheck/the glyph-selection logic asprotected virtual, so applications (or a subclass) can supply/override the visual for a givenTCheckBoxStatewithout patchingAdvOfficeButtons.pas.
Use case: In our application, TDBAdvOfficeCheckBox displays cbGrayed for NULL database fields. We would like this to be visually distinct and easily customizable (e.g. a different color/icon) without maintaining a forked copy of AdvOfficeButtons.pas across TMS updates.