Solved

Form Inheritance issues

Posted on 2003-11-03
9
156 Views
Last Modified: 2010-04-05
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?
0
Comment
Question by:dcl
  • 4
  • 4
9 Comments
 
LVL 5

Expert Comment

by:snehanshu
ID: 9676262
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
0
 
LVL 6

Expert Comment

by:swift99
ID: 9683213
see snehanshi's comment.  This is a common problem in complex heirarchies.
0
 
LVL 1

Author Comment

by:dcl
ID: 9691591
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

0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9691698
Can you post your DPR code? I have no clue of what's being talked about :-(
...Snehanshu
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Author Comment

by:dcl
ID: 9719634
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
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9720210
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
0
 
LVL 1

Author Comment

by:dcl
ID: 9737292
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
0
 
LVL 5

Accepted Solution

by:
snehanshu earned 250 total points
ID: 9737334
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
0
 
LVL 1

Author Comment

by:dcl
ID: 9769052
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
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now