Solved

Form Inheritance issues

Posted on 2003-11-03
9
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Correct Component for Shopping Cart. 2 121
how to send memory stream from ics Client To ics server ? 11 176
CheckListBox usage 3 81
Graphics32 under Delphi 10.1 Berlin 2 126
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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 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