5

I am venturing into making my own components in Delphi. I'm having difficulty getting started with component development.

I want to make a composite control ie a control made up of several other controls, eg like an address form or something like that.

I am descending from TWinControl. Would that be considered to be the correct choice?

The main thing is, I cannot see a way to visually design the component in D2010. Is this possible? eg drop some text boxes onto your component, as you would with a form. I'm hoping I don't have to hand code all the visual aspects to my own components..

Also any good links on delphi component dev would be very much appreciated - esp for composite controls. The docs are not A1, its a struggle. I searched a lot already, I'm still going nowhere fast.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
csharpdefector
  • 813
  • 8
  • 19

3 Answers3

7

If you're making something with multiple controls such as an address form, you might consider making it a frame instead of a control. Frames can be designed like windows, and re-used.

GrandmasterB
  • 3,396
  • 1
  • 23
  • 22
  • Thats music to my ears. I been using TPanel temporarily just to group things together before I made them into proper re-usable objects, I was unaware of TFrame. I knew there must be something, else it is not all that RAD! I'm hoping TFrames can be re-used on different forms, it looks that way from my initial reading. Thanks. – csharpdefector Aug 24 '10 at 20:55
  • You can re-use them on different forms - they're a class like any other! Drop one of the frames you've made on two different forms to try it out - they will work like dropping two of any individual component. – David Aug 25 '10 at 00:04
3

You'll have to describe it in code to compile, but you can use a trick to design the component visually at first.

Put a TPanel on the form, and let that stand for the base control. Arrange your sub-controls, then get the properties from text view. GExperts adds a menu option that will convert controls on a form to code to generate them automatically, making this step a lot easier.

Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
2

Read my bog article on using Frames as Visual Components - don't forget your spring.
It is very easy: put everything on your Frame, register it as a component, register the sprig, and don't forget that at design time 'Visible=False' is being ignored.

I just explained this yesterday during my preconference workshop at the DelphiLive! conference :-)

--jeroen

Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154