Link to home
Start Free TrialLog in
Avatar of comptebidon81
comptebidon81

asked on

Trying to build a class with no property in it

I built a class that I will be accessed from another class (kinda like a record). I wanna start the class from nothing, but Delphi forces it to be a TObject. That would be ok if only there was no properties added to those I make. Is there anyway to make them disapear?
Here's a sample of my code:
    Ttest = Class
      Private
        function pGetProp: Byte;
        procedure pSetProp(const Value: Byte);

      Published
        Property MyProperty: Byte Read pGetProp Write pSetProp;


Avatar of kretzschmar
kretzschmar
Flag of Germany image

? tobject didn't have propertys just methods

could you explain a bit more
Avatar of comptebidon81
comptebidon81

ASKER

well, methods or properties, I don't wanna see them.
All I wanna see when I use my Class is the properties or Methods I defined.  (with the code completion)
I have to find a way either to hide those methods of the TObject, or to start my class out  of nothing.
I don't think this is possible...
What do you mean not possible?
TObject is a class. It was created out of nothing or at least has a Parent that was. If they managed to create it, why woudn't I be able to do the same?
If you define a new class like this

TMyObject = class     // no ancestor specified
  ...
end;

it will automatically be derived from TObject. This is what the manual says.
It is not possible because, the delphi compiler is TObject aware. It forces all classes to be descendents of the TObject. However TObject does not have any properties. So all the properties you define are alone.

regards
// peymanz
There might not be any properties, but there is a lot of functions and procedures like AfterConstruction and all those generally usefull things. Well, right now, their more anoying than usefull.

By the way, thanks for the explanation peymanz...
You can use a stinky record or a pointer list to build a class like thing without additional methods/properties. But then Delphi doesn't know that it is a class like thing, so code completion doesn't work on it nor all the other things that Delphi tries to help class builders with.

If you want all those Delphi goodies, you have no choice than using the keyword "class". And in that case Delphi silently forces you to use TObject as the class parent. That's it. I'm sorry, you have no choice.

Regards, Madshi.
So you say I have to choose between a record (wich will give me weeks and weeks of work) or to go on with the Class and try not to see those unwanted lines in the code completion?
 If only I could Hide them somehow. ...
if y're that concerned with your properties not being the only ones that come up, prefix them with and underscore (or whatever makes you comfortable) so they all come up in the same place.

An ugly solution I know....but y're trying to use the tool (Delphi) in a way it was not designed to be used.

Ed
Maybe you can redeclare the methods/properties of TObject in your class, moving them to the private area. You'll get warnings as a result (but you can turn them off with a switch). In that case I guess that code completion will only show YOUR methods/properties, if code completion is used in a unit other than the one in that your object is defined. In the unit where your object is defined, you'll nevertheless see all methods.

I'm not sure if this idea would work at all, I've not tested it, it's just an idea...

Regards, Madshi.
ASKER CERTIFIED SOLUTION
Avatar of Igor UL7AAjr
Igor UL7AAjr
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot, Igor! You saved me!
Hmmm... Sorry for giving false information to you. I didn't remember this "object". Never used it...
Madshi,
do you never use Turbo Pascal?
Sorry, just a joke :-)
------
Igor
I used it some years ago, but I can't remember having used the keyword "object". At the Turbo Pascal times I had not much reason to do object oriented programming. There records just were perfect...