1

I have a TJVSegmentedLEDDisplay control (from the JVCL) that I want to use as a timer. Accordingly, it has five places, two for hours, two for the minutes, and a colon between the two numbers (i.e. 12:34). After hours of experimenting and searching, I still cannot figure out how to access each individual digit programmatically. It seems to me that it should be something like:

LEDControl.Digits[Index].Text

...but, obviously, it's not.

Any thoughts ?

TLama
  • 75,147
  • 17
  • 214
  • 392
Brian
  • 197
  • 2
  • 10

1 Answers1

1

The TJvCustomSegmentedLEDDigit.Text property, which you have tried to access is protected by a mistake I'd say, since then except direct modifying of the Text property, which is not much comfortable for this I couldn't find a way how to change the individual segment values. However, you can workaround this protected access e.g. by an interposer class:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, JvExControls, JvSegmentedLEDDisplay;

type
  TLEDDigit = class(JvSegmentedLEDDisplay.TJvCustomSegmentedLEDDigit);

type
  TForm1 = class(TForm)
    Button1: TButton;
    JvSegmentedLEDDisplay1: TJvSegmentedLEDDisplay;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  TLEDDigit(JvSegmentedLEDDisplay1.Digits[0]).Text := '1';
  TLEDDigit(JvSegmentedLEDDisplay1.Digits[1]).Text := '2';
end;

end.
TLama
  • 75,147
  • 17
  • 214
  • 392
  • I got no feedback, so how is it going ? – TLama Dec 13 '12 at 02:01
  • Sorry! I hadn't been able to check it until just now. Using your code, I get the following message: "'TJvCustomSegmentedLEDDigit' does not contain a member named 'Text'. While writing up the test code, however, I discovered that I'd neglected to create any TJvSegmentedLEDDigits before assigning to JvSegmentedLEDDisplay.Text. If you create one TJvSegmentedLEDDigit for each character in whatever string you want to assign, then you can set TJvSegmentedLEDDisplay.Text. – Brian Dec 13 '12 at 18:59
  • Then you must have a different version of JVCL than me (almost the most recent one). The code I've posted is of course tested and that property documented. The `TJvSegmentedLEDDisplay.Text` property I've also mentioned, but it gives not much comfortable way to set the text for a single digit. – TLama Dec 13 '12 at 19:07
  • I'm using JVCL 3.45 with JCL 2.31. Putting just a TJvSegmentedLEDDisplay and a button on a blank form (which adds JvExControls & JvSegmentedLEDDisplay to uses), I still get a red underline under .Text which hovering over produces "'TJvCustomSegmentedLEDDigit' does not contain a member named 'Text'". The compile error is "[DCC Error] Unit1.pas(31): E2362 Cannot access protected symbol TJvCustomSegmentedLEDDigit.Text". – Brian Dec 13 '12 at 20:43
  • Sorry, I forgot that you must have a subclass to access the protected `Text` property of a segment. Updated... – TLama Dec 13 '12 at 21:04