Form Inheritance issues

I have created the following form class hierachy
TFrom -> PaysysForm ->PaysysDataEntryForm
PaysysForm adds some properties & methods
PaysysDataEntryForm includes some standard controls such as dbnavigator & buttons

I have created a form called MainForm, based on PaysysDataEntryForm.
It is the only form in the project
The project compiles & runs fine.
However, I cannot open MainForm in the IDE, it complains that it cannot find the parent class definition for TPaysysDataEntryForm.  I have to open all of the source files for all of the parent classes, before I can open the MainForm.  Does anyone know why this would happen?
LVL 1
dclAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

snehanshuCommented:
Perhaps the problem is that the unit files of your derived forms are not present in Delphi's library path.
Are the unit files for PaysysDataEntryForm and PaysysForm in different directories (Different than where your project is)? If so, include the path of these directories inTools -> Environment Options -> Library -> Library Path

HTH,
...Snehanshu
swift99Commented:
see snehanshi's comment.  This is a common problem in complex heirarchies.
dclAuthor Commented:
Hi there

Thanks for the suggestion - I checked the paths & they were OK
After looking around for a while I noticed that the list of forms in the Project-Options did not include the intermediate ancestor forms.  I think this was becuase I had commented out the var... line in the class declaration unit.  Putting this back has fixed most of the problem.

My only problem now is that I can't set my MainForm as the Project Main Form.  It is the only autocreate form in the project, but the only form in the Main Form selection list is my ancestor form immediately descended from TForm

Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

snehanshuCommented:
Can you post your DPR code? I have no clue of what's being talked about :-(
...Snehanshu
dclAuthor Commented:
Hi Snehanshu

Here is my dpr

program LoanType;

uses
  Forms,
  PaySysForm in '..\Common\PaySysForm.pas' {frmPaySysForm},
  PaysysDataControls in '..\Common\PaySysDataControls.pas',
  PaySysFrame in '..\Common\PaySysFrame.pas' {fraPaysysFrame: TFrame},
  MainForm in 'MainForm.pas' {frmMainForm: TfrmPaySysForm},
  DataEntryControls in '..\Common\DataEntryControls.pas' {fraDataEntryControls: TFrame},
  PaySysDataEntryForm in '..\Common\PaySysDataEntryForm.pas' {frmPaysysDataEntryForm: TfrmPaySysForm};

{$R *.res}

begin
  Application.Initialize;
  Application.Title := 'Loan Types';
  Application.CreateForm(TfrmMainForm, frmMainForm);
  Application.Run;
end.

========= End of DPR

This is from PaySysDataEntryForm.pas

type
  TfrmPaysysDataEntryForm = class(TfrmPaySysForm)
    fraDataEntryControls: TfraDataEntryControls;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var                                                                                 // These 2 lines
  frmPaysysDataEntryForm: TfrmPaysysDataEntryForm;      // had been commented out

implementation

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

Now when I select "Project" - "Options" & the "Forms" tab, to select the main form for the project, frmMainForm is not in the "Main Form" combo, but only frmPaySysForm
snehanshuCommented:
dcl,
  It must be some thing about the way you have created the project.
  I have never seen such a thing happening and have little clue why it could happen.
  But here are a few things I noticed:


  MainForm in 'MainForm.pas' {frmMainForm: TfrmPaySysForm},
  PaySysDataEntryForm in '..\Common\PaySysDataEntryForm.pas' {frmPaysysDataEntryForm: TfrmPaySysForm};

  Your main form seems to have been derived from TfrmPaySysForm and not TfrmPaysysDataEntryForm as specified in your original post.
  I would suggest you make a clean start, with a new project and
1) Add the expanded path of "..\Common" to Project -> Options -> irectories/Conditionals -> Search Path
2) add files to the project (Shift-F11) in the following order:
  a) PaySysForm
  b) PaysysDataEntryForm
3) Create MainForm by File -> New -> Other -> <Project Name> -> frmPaysysDataEntryForm -> OK

If there is still a problem, then it may still be a problem with your PaysysDataEntryForm. So, you could review it.

Let me know if that helps.
...Snehanshu
dclAuthor Commented:
Thanks Snehanshu

That was well spotted:
- MainForm.pas contains "TfrmMainForm = class(TfrmPaysysDataEntryForm)" so I don't know why Delphi is calling it a TfrmPaySysForm - but that must be the problem.

I tried rebuilding the project but it all ended up the same.

PaysysDataEntryForm is very simple:

type
  TfrmPaysysDataEntryForm = class(TfrmPaySysForm)
    fraDataEntryControls: TfraDataEntryControls;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmPaysysDataEntryForm: TfrmPaysysDataEntryForm;

---
All it has is a frame with a whole lot of controls on it.
I'm not sure where to go from here
snehanshuCommented:
dcl,
  Without the actual code I won't be able to help much
  I would suggest you do a step-by-step debugging. Like, first create a project with only PaysysForm and compile and run that.
  Then, a project with PaysysForm and PaysysDataEntryForm. Compile and run that. Then
  PaysysForm ->PaysysDataEntryForm -> MainForm
  I am sure, along the way, you would come across some problem and once you solve thatm you would be done.
  Also, I hope you have added the path of your controls to the search path. It seems you have a lot of supporting files in the "Common" directory.
  A little systematic approach should get you there.
...Snehanshu

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dclAuthor Commented:
Thanks for all your help snehanshu

I may not have time to do this for a while, as it is not ciritical to the program working.
If I ever solve it I will let you know
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.