Solved

Form parameter

Posted on 2000-03-29
2
123 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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.

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

22 Experts available now in Live!

Get 1:1 Help Now