Board index » delphi » ReadComponentResFile

ReadComponentResFile

Hello,

I'm not sure if this is the right news group to post this. If not, just
direct me to the right one.

I'm trying to accomplish writing and reading components to and from a file.
I've managed to save the component (a TPanel type) with its inserted
components (e.g. components of TLabel type) to a resourcefile using
WriteComponentResFile ('MyResource.res', APanel); Now I want to read the
saved panel with its inserted components, but I'm having problems figuring
out how to do it. I'm trying to use the ReadComponentResFile, but I'm not
sure how to use it. I would thought something like this should work:

    APanel := TPanel(ReadComponentResFile('MyResource.res', APanel);

but I'm getting this error message when the line is executed:

    Class TLabel not found.

What should I do to make this work? Is there an easier way to do this?

Best regards
S?ren Tauber Lassen
Tauber Data

 

Re:ReadComponentResFile


This seems to work.

procedure TForm1.Button1Click(Sender: TObject);
begin
  WriteComponentResFile('C:\Test', Panel1);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
    // Loads Panel1 with the information from the Res File.
    ReadComponentResFile('C:\Test', Panel1);
end;

"S?ren Tauber Lassen" <s...@tauberdata.nospam.dk> wrote in message
news:3b94d059_2@dnews...

Quote
> Hello,

> I'm not sure if this is the right news group to post this. If not, just
> direct me to the right one.

> I'm trying to accomplish writing and reading components to and from a
file.
> I've managed to save the component (a TPanel type) with its inserted
> components (e.g. components of TLabel type) to a resourcefile using
> WriteComponentResFile ('MyResource.res', APanel); Now I want to read the
> saved panel with its inserted components, but I'm having problems figuring
> out how to do it. I'm trying to use the ReadComponentResFile, but I'm not
> sure how to use it. I would thought something like this should work:

>     APanel := TPanel(ReadComponentResFile('MyResource.res', APanel);

> but I'm getting this error message when the line is executed:

>     Class TLabel not found.

> What should I do to make this work? Is there an easier way to do this?

> Best regards
> S?ren Tauber Lassen
> Tauber Data

Re:ReadComponentResFile


Hmm... My msg didn't seem to get through.

"Rich Todosichuk" <rtodosic...@ezecastle.com> skrev i en meddelelse
news:3b9508f6_2@dnews...

Quote
> This seems to work.

> procedure TForm1.Button1Click(Sender: TObject);
> begin
>   WriteComponentResFile('C:\Test', Panel1);
> end;

> procedure TForm1.Button4Click(Sender: TObject);
> begin
>     // Loads Panel1 with the information from the Res File.
>     ReadComponentResFile('C:\Test', Panel1);
> end;

True, but not if the panel owns other components, such as TLabels, in which
case it raises the exception "Class TLabel not found".

--

Best regards

S?ren Tauber Lassen
Tauber Data
s...@tauberdata.nospam.dk

Re:ReadComponentResFile


"Rich Todosichuk" <rtodosic...@ezecastle.com> skrev i en meddelelse
news:3b9508f6_2@dnews...

Quote
> This seems to work.

> procedure TForm1.Button1Click(Sender: TObject);
> begin
>   WriteComponentResFile('C:\Test', Panel1);
> end;

> procedure TForm1.Button4Click(Sender: TObject);
> begin
>     // Loads Panel1 with the information from the Res File.
>     ReadComponentResFile('C:\Test', Panel1);
> end;

True, it works, as long as the panel doesn't own other components, such as
labels, in which case it raises the exception "Class TLabel not found".

--

Best regards

S?ren Tauber Lassen
Tauber Data
s...@tauberdata.nospam.dk

Re:ReadComponentResFile


On Tue, 4 Sep 2001 19:41:38 +0200, "S?ren Tauber Lassen"

Quote
<s...@tauberdata.nospam.dk> wrote:

Hi S?ren,

perhaps this will help you:

 procedure TForm1.Button4Click(Sender: TObject);
begin

  RegisterClass(TLabel)  ; // Unit Classes

    // Loads Panel1 with the information from the Res File.
  ReadComponentResFile('C:\Test', Panel1);
 end;

Best regards,

Alexander Mauri

Quote
>Hmm... My msg didn't seem to get through.

>"Rich Todosichuk" <rtodosic...@ezecastle.com> skrev i en meddelelse
>news:3b9508f6_2@dnews...
>> This seems to work.

>> procedure TForm1.Button1Click(Sender: TObject);
>> begin
>>   WriteComponentResFile('C:\Test', Panel1);
>> end;

>> procedure TForm1.Button4Click(Sender: TObject);
>> begin
>>     // Loads Panel1 with the information from the Res File.
>>     ReadComponentResFile('C:\Test', Panel1);
>> end;

>True, but not if the panel owns other components, such as TLabels, in which
>case it raises the exception "Class TLabel not found".

>--

>Best regards

>S?ren Tauber Lassen
>Tauber Data
>s...@tauberdata.nospam.dk

Other Threads