Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Form inheritance and overriding functions.

Posted on 2001-08-10
8
Medium Priority
?
292 Views
Last Modified: 2010-04-06
I have a form which is used as a template (via inheritance) to create "real" forms (via New ... and choosing my template form).

(Don't know the right terminology, so please excuse me!).

The form contains a whole load of controls with some basic events behind them.

One of the events needs to call a validation routine.

This routine is different for each of the real forms.

So.

frmMaint is the template form.
frmMaintUsers is one of the new forms, based on frmMaint, frmMaintJobs is another.

The frmMaint form has an event on the OK button to determine if the values can be saved.

I would like to be able to have in the OK event something like ...

if (ValidateForm) then ...

Where ValidateForm can be different for each of the new forms as the actual things to be validated are different.

In the new forms, I am expecting something like ...

function TfrmMaintUsers.ValidateForm : Boolean;
begin
 inherited;
// Do my validation now.
 Result := whatever;
end;

I do not know how to declare this function in the template form nor in the new form so that it is inherited properly.

Ideas/suggestions/examples please.

Regards,

Richard Quadling.
0
Comment
Question by:Richard Quadling
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6372068
you could it define as a dummy as any other mehod like

function TTemplateForm.ValidateForm : Boolean;
begin

end;

or with the virtuel-directive
in your templateform type declaration

(just from head, misunderstanding possible)

meikl ;-)
0
 
LVL 4

Accepted Solution

by:
jsweby earned 600 total points
ID: 6372093
From where I'm sitting, instead of having a function that returns True/False, you should have a procedure with a variable parameter that takes the true/false result; then you can use the inheritance.

J.

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6372125
good point, j :-)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

by:jsweby
ID: 6372133
Thanks, k. Inheritance isn't my strong point, though...
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6372137
Hi RQuadling,

you can declare virtual method in frmMain form:

  TFrmMainForm = class(..)
   public
       function IsFormValid: Boolean; virtual; // abstract

and then write your own implementation on inherited forms.


-----
Igor.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6372152
hi igor :-)
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6372167
Hi meikl,
just reread your comment and found the same idea :-)

0
 
LVL 40

Author Comment

by:Richard Quadling
ID: 6372189
Thanks for the ideas.

I've got it working with a procedure and a variable parameter.

Regards,

Richard Quadling.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

810 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