Solved

how do I add custom properties to an activeForm?

Posted on 1998-02-24
2
179 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
Comment Utility
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
Comment Utility
philipleighs is correct....this really works....million thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
TcomboBox uninverted item 3 44
How to use Hashing sha1 in Delphi 2010 4 160
code issue 8 84
How to renew a Delphi rad-studio licence? 5 33
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…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

8 Experts available now in Live!

Get 1:1 Help Now