Glen Morse
Glen Morse

Reputation: 2593

Creating a new type

In delphi I would like to create a new type (Machine) that copies TShape. Mostly due to wanting to add more procedures and functions. For example i could do something like this

Machine.type('402') 

and it would draw the shape, but with a defined Height / width. and like this

Machine.before('Microclean');

and it would know where to put the shape.

So ..two part question.
1. Is making a new type sound like what i need? 2. How do i make a new blank type, Thus as its own unit and can add my new procedures to it?

thanks Glen

Upvotes: 1

Views: 263

Answers (1)

Keith Miller
Keith Miller

Reputation: 1768

Sounds like you need a new class that inherits from TShape:

TMachine = class(TShape)
public
  procedure MyType(const AType: string);
  procedure Before(const ABfore: string);
end;

You could then provide code for the two procedures.

Note that you cant use type for a procedure name - that is a reserved word. Also it is a Delphi convention (but not a requirement) to prefix class names with a 'T'

Upvotes: 4

Related Questions