Avatar of rfwoolf
rfwoolf
Flag for South Africa asked on

Problem with frames: Error reading form: "Class TFrameBalance not found"

I'm maintaining an existing application and the developer has made almost all of the forms 'dynamic', in other words they are not declared in the DPR file, they are not 'Auto-Create' forms and they are not 'Available forms'.

So now my problem with frames:
I have a form e.g.
  ..\Balance\Forms\BalanceForm.pas
  ..\Balance\Forms\BalanceForm.dfm
It uses a frame:
  ..\Balance\Forms\BalanceFrame.pas
  ..\Balance\Forms\BalanceFrame.dfm

If I open the frame into the IDE *first*, and *then* open the form *second* I get no problem.
But if I open the form *first* I get error:
=================
Error Reading Form
Class TFrameBalance not found. Ignore the error and continue?
=================

This same problem exists throughout the application every time there is a form that uses frames.

Please help :S

Here is some code that will hopefully help:

  ..\Balance\Forms\BalanceForm.pas
unit BalanceForm;

interface

uses
 ...
  AuthResultFrame,
  BalanceFrame;

type
  TFormBalance = class(TFormWizard)
    FrameAuthResult: TFrameAuthResult;
    FrameBalance: TFrameBalance;
    ...
  private
    ...
  public
  end;

var
  FormBalance: TFormBalance;

Open in new window


  ..\Balance\Forms\BalanceForm.pas
inherited FormBalance: TFormBalance
  ...
  inherited PanelMain: TPanel
    inherited Wizard: TbsWizard
      ...
        inline FrameBalance: TFrameBalance
          ...
        end
      object WizardPageResults: TbsWizardPage
        object GroupBoxAuthResults: TRzGroupBox
          object PanelAuthResults: TRzPanel
            inline FrameAuthResult: TFrameAuthResult
            end
          end
        end
      end
  end

Open in new window


==========================================================================

 ..\Balance\Forms\BalanceFrame.pas
unit BalanceFrame;

interface

uses
 ...
  CardListFrame;

type

  TFrameBalance = class(TFrame)
    ...
  private
    ...
    FFrameCardList: TFrameCardList;
  public
    ... 
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  end;

implementation

constructor TFrameBalance.Create(AOwner: TComponent);
begin
  inherited;
  FFrameCardList := TFrameCardList.Create(Self,GroupBoxCardNumbers,cstBalance);
  with FFrameCardList do
  begin
    Top := 17;
    Left := 2;
    OnUpdateMessage := DoUpdateMessage;
  end;
end;

destructor TFrameBalance.Destroy;
begin
  FFrameCardList.Free;
  inherited;
end;

Open in new window


 ..\Balance\Forms\BalanceFrame.dfm
object FrameBalance: TFrameBalance
  ...
  object GroupBoxCardNumbers: TRzGroupBox
    Left = 0
    Top = 65
    Width = 495
    Height = 283
    Align = alTop
    GroupStyle = gsStandard
  end
  ...
end

Open in new window


=====================================================================

  ..\Common\Forms\CardListFrame.pas
unit CardListFrame;

uses
  ...
  CardEditBoxFrame;

type
  TFrameCardList = class(TFrame)
  private
    ...
  public
    ...
    constructor Create(AOwner: TComponent; AParent: TWinControl; AScanType: TCardScanType); reintroduce;
    destructor Destroy; override;
  end;

implementation

constructor TFrameCardList.Create(AOwner: TComponent; AParent: TWinControl; AScanType: TCardScanType);
begin
  ...
  CreateEditBoxes(AOwner);
  ...
end;

destructor TFrameCardList.Destroy;
begin
  FListEditBoxes.Free;
  inherited;
end;

procedure TFrameCardList.CreateEditBoxes(AOwner: TComponent);
var
  ...
  CardEditBoxFrame: TFrameCardEditBox;
begin
  for i := 1 to (FMaxRows * FMaxColumns) do
  begin
    ColumnNumber := ((i-1) div FMaxRows) + 1;
    CardEditBoxFrame := TFrameCardEditBox.Create(AOwner);
    with CardEditBoxFrame do
    begin
      Parent := TWinControl(Self.FindComponent(Format('PanelBox%d',[ColumnNumber])));
      ...
    end;
    FListEditBoxes.Add(CardEditBoxFrame);
  end;
end;

Open in new window


  ..\Common\Forms\CardListFrame.dfm
object FrameCardList: TFrameCardList
  Left = 0
  Top = 0
  Width = 501
  Height = 170
  TabOrder = 0
end

Open in new window

Delphi

Avatar of undefined
Last Comment
rfwoolf

8/22/2022 - Mon
SOLUTION
Geert G

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Geert G

*add* the directories ...
rfwoolf

ASKER
Hi Geert

I did try that... once.. and the problem persisted,
but in theory that solution makes sense.
Let me try it again.
To be clear, everything is in one big folder, however there are a lot of 'subfolders', so I am going to add each and every subfolder (there are probably about 40) to the library path and try again
rfwoolf

ASKER
Silly me, in this example I just need to add the folders for this FormBalance,
but the problem is persisting :S
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
rfwoolf

ASKER
Okay sure if i add them to the project, and therefore make them an 'available' form, the problem will go away, but the developer never did this and maybe this was for a good reason?
My boss wants me to get this application compiling on my laptop, preferably exactly like the developer had it - if I add all these frames (and there are probably quite a few) to the project, perhaps there will be a difference in memory or something like that?
ASKER CERTIFIED SOLUTION
Emmanuel PASQUIER

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
rfwoolf

ASKER
epasquier>
It's so great to have your input on this one - I've done quite a bit of googling and saw different workarounds for this problem but they didn't seem to work and I had to wonder if I was doing something wrong.
One work around for example spoke about checking that in the DFM of the frame, you say *inherited* instead of *object* except for the 'base clase' ('base frame'). That's why I tried to paste all the 'original' source-code from the developer in case there's something amiss.

But like you say, the problem does appear to go away if you add the units to the project.

Yes, I'm using Delphi 7.

>>"if you open the form in the IDE, and inadvertently click OK on its error/question message about removing the component, you are screwed and will loose everything you might have changed in this frame components properties, and need to find a backup or redo it..."
--I'm not certain about this - I simply close the unit and choose not to save. This goes for any error you may get when opening a form and a class is missing, simply ignore / cancel and then close without saving.

Thanks for the helpful answer.
Emmanuel PASQUIER

> --I'm not certain about this - I simply close the unit and choose not to save.
> This goes for any error you may get when opening a form and a class is missing,
> simply ignore / cancel and then close without saving.

Yes, I concur, I made a shortcut in my mind. If you don't save, then you have no problems.
But since a while back I've been able to find a "temporary" workaround by opening the frame unit, then the form, and it works even without adding the frame to the project, there have been a time when I worked unsafely.
I have a few time forgot to open all the frames before the form, and clicked OK on the error, made changes in the code just because I needed to do it quickly, then leaved it at that, and forgot about the error and dfm modifications when the time came to save the project.... Not funny when the next day you reopen the project...
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
rfwoolf

ASKER
Oh and just FYI for anybody that reads this, its the updated Delphi 7, albeit it may be an 'old' update, I'm not sure if they released more than one
Emmanuel PASQUIER

And I think there is 95% chance that this problem is specific to Delphi 7 IDE.
I use also 5 and 2007, but less, for very specific reasons.
I am just not sure (5%) that this problem did not occurred with one of them.
SOLUTION
Geert G

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
rfwoolf

ASKER
Thanks guys. this helped.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy