troubleshooting Question

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

Avatar of rfwoolf
rfwoolfFlag for South Africa asked on
Delphi
12 Comments3 Solutions2378 ViewsLast Modified:
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;

  ..\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

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

 ..\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;

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

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

  ..\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;

  ..\Common\Forms\CardListFrame.dfm
object FrameCardList: TFrameCardList
  Left = 0
  Top = 0
  Width = 501
  Height = 170
  TabOrder = 0
end
ASKER CERTIFIED SOLUTION
Emmanuel PASQUIER
Freelance Project Manager
Join our community to see this answer!
Unlock 3 Answers and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros