I have my own VCL “LED indicator” component created using C++ Builder. It works well and I use it a lot in control systems projects to indicate things are on or off. I can select the colour of the “LED” at both design time and at run time as well as turning it off (which makes it grey).
But I had a small urgent job come up. The customer wanted the source code and the customer wanted some coloured indicators but in order to keep his costs down he didn’t want to buy my “LED indicator” component source code.
My solution was to use a TLabel component for each “indicator” and to make it’s size a square and to enter a single space character as the caption.
Then in my code I can update it by setting the colour of the TLabel component to what I need.
Here’s the code for the component from the form *.dfm file:
object DigOutLedIndicator: TLabel
Left = 71
Top = 82
Width = 20
Height = 20
AutoSize = False
Caption = ‘ ‘
Color = clNavy
ParentColor = False
Transparent = False
end
and here’s a simple C++ code snippet to show you how I change the colour to reflect an output state:
// in a header file somewhere….
const Graphics::TColor RemIOLedOffColour = clGray;
const Graphics::TColor RemIOLedOnColour = clSkyBlue;
// in C++ source code function…..
bool OutputIsOn = true; // actually comes from somewhere in the code
DigOutLedIndicator->Color = OutputIsOn ? RemIOLedOnColour : RemIOLedOffColour;
It all works well and is quick and easy ! It’s not as good as my “LED indicator” component (which is circular with a bezel and tiny reflection hint on the surface so it looks like an LED dome) but it does the job.
You must be logged in to post a comment.