Solved

how do I add custom properties to an activeForm?

Posted on 1998-02-24
2
183 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Machine not responding during CopyFile() 3 104
Simple Delphi Question 9 96
shape, triangle, dbctrlgrid 3 17
FMX TEdit KeyUp handler detecting  "enter" key 4 14
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 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