We help IT Professionals succeed at work.

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

rfwoolf
rfwoolf asked
on
2,295 Views
Last Modified: 2012-05-10
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

Comment
Watch Question

Geert GOracle dba
CERTIFIED EXPERT
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Geert GOracle dba
CERTIFIED EXPERT
Top Expert 2009

Commented:
*add* the directories ...

Author

Commented:
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

Author

Commented:
Silly me, in this example I just need to add the folders for this FormBalance,
but the problem is persisting :S

Author

Commented:
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?
Freelance Project Manager
CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
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 PASQUIERFreelance Project Manager
CERTIFIED EXPERT
Top Expert 2010

Commented:
> --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...

Author

Commented:
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 PASQUIERFreelance Project Manager
CERTIFIED EXPERT
Top Expert 2010

Commented:
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.
Geert GOracle dba
CERTIFIED EXPERT
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks guys. this helped.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.