River_Forest

Member since: Friday, 11 November 2016
Last login: 3 days ago
Profile viewed: 137 views

No Rank
Points: 0

River_Forest replied to the topic 'Array of TLabel objects' in the forum. 4 weeks ago

Yes, I think the issue could be resolved by some kind of casting, but I've made various experiments and not found a way to do it. I wish that someone who knew C++ were following this thread and could provide this final step.
River_Forest
PS You're correct that the formatting that occurs when one posts pasted copies of code is a kink in the Forum system. Someone at Embarcadero should fix that.

Read More...

River_Forest replied to the topic 'Array of TLabel objects' in the forum. 4 weeks ago

It turns out I do need to access later the various TLabel objects, which I think means I must add them to a TListObject. I've done that successfully, but I can't figure out how to get them back, so to speak. What if, for example, I need to access the third label to change its 'Visible' setting to 'false'?
By analogy with TStringList objects, I tried:
labelList->Items[2]->Visible = false;
but I get the message 'Visible' is not a member of 'TObject', but since the object at index 2 is a TLabel, it seems to me that 'Visible' ought to be one of its Members.
I also tried the following:
TLabel * dummyLabel;
dummyLabel = labelList->Items[2];
but that gives me the error message, Cannot convert 'TObject' to 'TLabel'. Since what was put into TObjectList with the Add() was a TLabel, I don't understand why it is no longer a TLabel or how to convert it back to one.
The code is below. Thanks in advance. (C++ notation rather than Delphi would be much appreciated.)
River_Forest
====================
TObjectList * labelList;
TLabel * lbl;
labelList = new TObjectList;
String name = "";
for (int i = 0; i < 4; i++) {
lbl = new TLabel(Owner);
name = "Label_number_";
name = name + IntToStr(i);
labelList->Add(lbl);
lbl->Visible = true;
lbl->Parent = Form10;
lbl->Text = name;
lbl->Position->X = 10;
lbl->Position->Y = 10 + 100*i;
}
labelList->Items[2]->Visible = false;}

Read More...

River_Forest replied to the topic 'Array of TLabel objects' in the forum. 1 month ago

My turn to apologize for the format. Somehow carriage returns disappeared. The code is:
TLabel * lbl;
String name = "";

for (int i = 0; i < 4; i++) {
lbl = new TLabel(Owner);
name = "Label_number_";
name = name + IntToStr(i);
lbl->Visible = true;
lbl->Parent = Form10;
lbl->Text = name;
lbl->Position->X = 10;
lbl->Position->Y = 10 + 100*i;
}

Read More...

River_Forest replied to the topic 'Array of TLabel objects' in the forum. 1 month ago

Dear Germán,
Your idea solves my problem. In fact, I won't even need to do any more than just create a sequence of labels with a 'for' loop, using IntToStr() to adjust the names or texts of the labels. (I tweaked your format; I'm not sure how you use colon (:) and colon_equals (:=), so below is the code that works.)
I do have one question. This code seems to me to create one TLabel, and then repeatedly rename it and reposition it. So, I don't understand why all four labels appear. I would have thought only the last one would appear. Are there really four TLabel objects here or just one, and if only just one, how can it appear four times in different places (and survive being refreshed)? Thanks if you can clear up that last point.
TLabel * lbl;String name = "";
for (int i = 0; i < 4; i++) {lbl = new TLabel(Owner);name = "Label_number_";name = name + IntToStr(i);lbl->Visible = true;lbl->Parent = Form10;lbl->Text = name;lbl->Position->X = 10;lbl->Position->Y = 10 + 100*i;}

River_Forest

Read More...

River_Forest created a new topic ' Array of TLabel objects' in the forum. 1 month ago

Is there a (I hope simple) way to create an array of TLabel objects. My project will have up to four labels that conceptually would lend themselves to being an array. How would one do this?
River_Forest

Read More...

River_Forest replied to the topic 'sent messages' in the forum. 2 months ago

Has this been fixed? I can use the URLs given in this thread to find my messages, but I can't find a link on any page to go to them directly.
River_Forest

Read More...

River_Forest is friends with Roger Cigol