Solved

how do I add custom properties to an activeForm?

Posted on 1998-02-24
2
180 Views
Last Modified: 2010-04-06
I am using the Edit | Add to Interface Option, on an ActiveForm which is blank (for testing). I type in a property name as property test:integer, and delphi 3 sets up the appropriate declarations in the code with the skeletons for the get and set methods. However, I cannot compile with  Result:=test in the get procedure, or test:=value in the set procedure....Please Help me solve this problem...
0
Comment
Question by:abdi
2 Comments
 
LVL 3

Accepted Solution

by:
philipleighs earned 200 total points
ID: 1359753
Hi,

You should not assign to or read a property from inside the Get or Set methods.
You should assign to and read from a private variable.

Here is some (rough) code: (there may be some syntax errors)

interface

type
  Tmyform = class( tform )
    private
       FMyVariable: Integer;  //this is where the number is *stored*
    protected
       function GetMyVariable: Integer;
       procedure SetMyVariable(AMyVariable: Integer);
    public
      property MyVariable: Integer read GetMyVariable write SetMyVariable;
   end;


implementation

function Tmyform.GetMyVariable: Integer;
   begin
      Result := FMyVariable;
   end;

procedure Tmyform.SetMyVariable(AMyVariable: Integer);
  begin
     FMyVariable := AMyVariable;
     //do other things here that care when MyVariable changes
  end;

end.


That is pretty much it. By the sounds of things, you don't have the private variable declaration. A property itself is not a variable. You must tell a property what variable/function/procedure to read and write to.

If you wanted to bypass the Get and Set routines you could change the property declaration to:

property MyVariable: Integer read FMyVariable write FMyVariable;

Good luck,
Phil.

0
 

Author Comment

by:abdi
ID: 1359754
philipleighs is correct....this really works....million thanks
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

Title # Comments Views Activity
Intraweb submit form as a POST request 4 259
delphi exception 7 61
tidtcpserver connection lost handle 2 69
Graphics32 under Delphi 10.1 Berlin 2 34
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

929 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