Solved

Form parameter

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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Downloading email attachments 2 85
Firemonkey DbLookupComboBox equivalent ? 2 68
Tvertscrollbox like a whatsapp layout delete messages 1 39
enhance the following code 3 42
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…

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