Solved

how do I add custom properties to an activeForm?

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month9 days, 8 hours left to enroll

623 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