Solved

Form parameter

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

Industry Leaders: 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!

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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