River_Forest

Member since: Friday, 11 November 2016
Last login: 2 months ago
Profile viewed: 235 views

No Rank
Points: 0

River_Forest replied to the topic 'Array of TLabel objects' in the forum. 2 months ago

PPS Yes, I was thinking that some kind of cast was a way to solve the problem. See #6533 of 1 month and 2 weeks ago. But as I discovereed and you suggested, the array is better than the single TObjectList object.
River_Forest

Read More...

River_Forest replied to the topic 'Array of TLabel objects' in the forum. 2 months ago

Dear Roger,
Actually, in the mean time I had done essentially what you suggested, i.e., create an array of TLabel objects, rather than a single TOjbectList object. (I stumbled on following Stroustrup's advice, without being aware of it.) So, the code I have is conceptually what you're suggesting. I don't have the line
#include <vector>
To declare my array of TLabel objects, I have
TLabel * labelWriteInfo[6];
in my .h file, and then in the .cpp I have
for (int i = 0; i < 6; i++) {
labelWriteInfo = new TLabel(Owner);
labelWriteInfo->Parent = (Form1);
}
This gets me to the same place. I note with interest your alternate way of doing it, which presumably would require the inclusion of . Do you see a disadvantage to the way I'm doing it above?
River_Forest
PS Ah, I have fond memories of the Mozart horn concerti. It has been so long since I got my lip in shape. At the moment, in retirement, I'm trying to learn some piano as an alternate musical outlet, and one that doesn't require me to find a group with which to play, which I found to be important when I was playing Horn.
PPS No idea what's going on with the text being stripped out between the angle brackets, although I suspect you're correct that it's connected with HTML. I have a <> icon in my edit area, and when I hover over it with my mouse, it says "source code." Is that relevant? Is that an easier way for us to copy source code and paste it into these messages?


Read More...

River_Forest replied to the topic 'Array of TLabel objects' in the forum. 3 months ago

Dear Markus Humm,
Thank yoiu. It turned out I was able to do everything I needed to do with a simple array of TLabel objects.
In my main .h file I have
TLabel * labelWriteInfo[6];
and in the
TForm1::TForm1() code I have
for (int i = 0; i < 6; i++) {labelWriteInfo = new TLabel(Owner);labelWriteInfo->Parent = (Form1);}
and then I can access the labels individually as indexed, e.g.,
labelWriteInfo[1]->Visible = false;
So, I don't need to mess with generics, thank goodness.
Incidentally, yours was Delphi code, right?
River_Forest


Read More...

River_Forest replied to the topic 'Moving to a new computer' in the forum. 3 months ago

Dear Roger,
Thanks. That's all a great help. Among many things I didn't appreciate the meaning of "build" and "make." I was looking in menus for the word "compile." I should simply play around with the IDE more than I do. I'm sure I'd learn a lot.
River_Forest

Read More...

River_Forest replied to the topic 'Moving to a new computer' in the forum. 3 months ago

Dear Roger,
This sounds right. I do have some questions about it, though, and I'm not sure how best to formulate those questions. I guess the biggest one is: what is the role of the cbproj file? I found that I can accomplish what I want by copying all the relevant files into one folder on a flash drive, including the existing cbproj file with them, and then doing an Open Project command from the IDE and selecting the relevant cbproj file from the folder on the flash drive. I don't seem to have had to create the folder hierarchy you were suggesting, and I don't have a separate /C Code file. Were those just examples?
Incidentally, two minor questions: can I rename a project simply by using Windows Explorer and renaming the cbproj file, maintaining, of course, the same extension, or do I have to implement the project name change throughout all the files some how. Also, how can I compile my code without running it? Sometimes I simply want to make sure it simply compiles. Frankly, when inputting code, I like to compile every few lines just to catch the typographical errors as they occur.
Thanks (as always!)
River_Forest

Read More...

River_Forest replied to the topic 'Moving to a new computer' in the forum. 3 months ago

Interesting. Thanks for replying. I am "only" trying to copy a project from the desktop on which I usually work to my laptop, so that I can work on the project when I travel (and then update the version on the desktop when I get home to reflect the work done). At least I don't have the 32-bit versus 64-bit problem; both devices are 64-bit. But, as you say, this should not be hard. It is frustrating that apparently no one official does listen to these conversations, and so far I've found tech support difficult to contact or use. But again, thanks for the reply.
River_Forest

Read More...

River_Forest replied to the topic 'Moving to a new computer' in the forum. 3 months ago

Did you ever get any response to this or any help with it? I am facing the same problem.
River_Forest

Read More...

River_Forest replied to the topic 'Array of TLabel objects' in the forum. 4 months 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 months 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. 4 months 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. 4 months 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. 4 months 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. 5 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