Solved

Form parameter

Posted on 2000-03-29
2
124 Views
Last Modified: 2010-04-04
I want to avoid a duplicated program.
So, I neet to make a funtion or procedure.

In the next exsample, only formname is different on several cases..
How do I make a procedure?
I think that I have to pass a Form name to function...

ex) ======================================
var
   FormGF1A2200 : TFormGF1A2200;
   FormGF1A3300 : TFormGF1A3300;
   recCnt : Integer;
   layer : String;
begin
 if layer = 'GF1A2200' Then
 begin
   FormGF1A2200 := TFormGF1A2200.CreateSelf);
   recCnt := FormGF1A2200.fnOpen_Query(sSelObjId);
   If (recCnt> 1) then
       FormGF1A2200.Close
   else
       FormGF1A2200.ShowModal;
 end
 else if layer = 'GF1A3300' Then
 begin
   FormGF1A3300 := TFormGF1A3300.CreateSelf);
   recCnt := FormGF1A3300.fnOpen_Query(sSelObjId);
   If (recCnt> 1) then
       FormGF1A3300.Close
   else
       FormGF1A3300.ShowModal;
 end;


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

0
Comment
Question by:mjcho
2 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 2667904
I didn't understand you problem, but if you want to make a parameter for a form you can do this:

procedure YourProc(Sender: TYourForm);
begin
  TYourForm(Sender).Color:=...
  TYourForm(Sender).Show:=...

Motaz
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 100 total points
ID: 2668037
You can change your code to this to do what you want:

type
  TMyForm = class(TForm)
    public
      Function fnOpen_Query(...) : Integer; Virtual;
  end;

  TFormGF1A2200 = class(TMyForm)
    public
      Function fnOpen_Query(...) : Integer; Override;
  end;

  TFormGF1A3300 = class(TMyForm)
    public
      Function fnOpen_Query(...) : Integer; Override;
  end;

  TMyFormClass = class of TMyFOrm;

var
   recCnt : Integer;
   layer : String;

Procedure TWhatever.DoAction(TheFormClass : TMyFormClass);
var
  TheForm : TMyForm;

begin
   TheForm := TheFormClass.Create(Self);
   recCnt := TheForm.fnOpen_Query(sSelObjId);
   If (recCnt> 1) then
     TheForm.Close
   else
     TheForm.ShowModal;
end;

begin
 if layer = 'GF1A2200' Then
   DoAction(TFormGF1A2200)
 else
  if layer = 'GF1A3300' Then
     DoAction(TFormGF1A3300);
 end;

I hope that is clear!

Cheersa,

Raymond.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

943 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

10 Experts available now in Live!

Get 1:1 Help Now