?
Solved

Form parameter

Posted on 2000-03-29
2
Medium Priority
?
128 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 300 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

Technology Partners: 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

801 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