Solved

Trying to build a class with no property in it

Posted on 2001-07-12
16
133 Views
Last Modified: 2013-11-23
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;


0
Comment
Question by:comptebidon81
  • 5
  • 4
  • 2
  • +4
16 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6278459
? tobject didn't have propertys just methods

could you explain a bit more
0
 

Author Comment

by:comptebidon81
ID: 6278477
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.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6278502
I don't think this is possible...
0
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 

Author Comment

by:comptebidon81
ID: 6278553
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?
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6278581
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.
0
 
LVL 2

Expert Comment

by:peymanz
ID: 6278588
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
0
 

Author Comment

by:comptebidon81
ID: 6278614
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...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6278632
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.
0
 

Author Comment

by:comptebidon81
ID: 6278871
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. ...
0
 

Expert Comment

by:Bill_Door
ID: 6279230
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
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6279642
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.
0
 
LVL 9

Accepted Solution

by:
ITugay earned 100 total points
ID: 6279922
Hi comptebidon81,

if you'd like to build it from "nothing" then "class" is wrong ancestor, because it has predefined members. Would be better build it something like this:

  TMyObj = object
  private
    FProp: Integer;
    procedure SetProp(I: Integer);
  public
    property Prop: Integer read FProp write SetProp;
  end;

------
Igor.
0
 

Author Comment

by:comptebidon81
ID: 6280550
Thanks a lot, Igor! You saved me!
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6280567
Hmmm... Sorry for giving false information to you. I didn't remember this "object". Never used it...
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6280651
Madshi,
do you never use Turbo Pascal?
Sorry, just a joke :-)
------
Igor
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6281170
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...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 276
Comparing dates in Delphi. Greater than/ Less than 3 156
Downloading email attachments 2 74
Delphi and Access based Enumeration 9 64
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

831 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