Please see "Transparency on tool buttons is not practical and is broken - ID: 2817930"
I'm still having the problem with version 6.30.5.
TColor::Grey = RGB(192,192,192) yet none of the backgrounds with that colour come out as transparent,
Consequently, I have overriden the TButtonGadget PaintFace function with exactly the same code that you have in buttonga.cpp except that
where you have:
TUIFace face(rect, celArray, TColor::Sys3dFace);
bool flat = Window->GetFlatStyle() & TGadgetWindow::FlatStandard;
I have:
TUIFace face(rect, celArray, TColor(192, 192, 192));
bool flat = Window->GetFlatStyle() & TGadgetWindow::FlatStandard;
I looked at the gadgets example you said you were viewing and the only difference when instantiating is that I'm using a string based resource name rather than an ID. Also that Im adding it to a dockable control bar as opposed to a control bar.
Note that TColor::LtGray == RGB(192, 192, 192); and TColor::Gray == RGB(128, 128, 128).
The mapping of the transparent color happens in TDib::MapUIColors. Here TColor::LtGray (not TColor::Gray!) in the source bitmap is mapped to TColor::Sys3dFace, which is the transparent color used by TButtonGadget::PaintFace:
..TUIFace face(rect, celArray, TColor::Sys3dFace);
At this point celArray should have been built by TButtonGadget::BuildCelArray, which calls TButtonGadget::GetGlyphDib, which in turn calls TDib::MapUIColors.
BuildCelArray is called by TButtonGadget::GetDesired as part of setup, as well as by TButtonGadget::SysColorChange in response to GUI color changes.
Set a break-point in your code in this code path to debug your code and identify the problem. Please retest with the latest version, and post complete example code demonstrating the problem if it still persists.