Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Trying to build a class with no property in it

Posted on 2001-07-12
16
Medium Priority
?
139 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 400 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 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