3

I am trying to build a custom control which can draw the outline and pins of an integrated circuit.

At present I am using 2 frames, one holding a panel which will represent the package outline. THis frame will be place on a form. The other frame will represent a pin which will contain a shape to represent the pin and two labels, one for pin number one for pin description. My plan is to create the pins dynamically according to package aspect ratio and number of pins.

Are frames a good basis for this or are there better alternatives.

John Barrat
  • 810
  • 4
  • 15
  • 2
    I don't think this is a good idea. If I were you, I'd do everything manually in code instead. Create a custom control derived from `TCustomControl` (which will give you a HWND and a possible keyboard interface -- if you don't need that, use `TGraphicControl` instead). Some examples: Direct2D: https://stackoverflow.com/a/64867049/282848, https://algosim.org/SynViewSource/SProgressIndicator.html; GDI: https://stackoverflow.com/a/7783559/282848, https://stackoverflow.com/a/12600297/282848, https://stackoverflow.com/a/3902049/282848, https://stackoverflow.com/a/3991408/282848. – Andreas Rejbrand May 03 '21 at 07:37
  • Thank you, these examples are very helpful. It gives me a really good starting point. I was beginning to think Frames were the wrong choice which is why I ask the original question – John Barrat May 03 '21 at 08:42

1 Answers1

3

A frame is a good starting point but is heavy. Probably the best solution is to build a custom control. As ancestor, you could start either with TGraphicControl or TWinControl depending on the features you need. Read the documentation to select the best fit for your case.

TCustomControl which derive from TWinControl is a good ancestor for controls that wrap Windows screen objects but perform their own rendering.

The documentation I linked above gives examples of controls.

fpiette
  • 11,983
  • 1
  • 24
  • 46
  • Thank you, a read of TCustomControl appears to be a good starting point for what I want to do, I will give it a go. The other challenge I am going to have is writing text rotated 90 deg but I will tackle that when I have the basic outline control working. – John Barrat May 03 '21 at 07:58
  • @JohnBarrat: Writing text rotated is simple. Set the TFont.Orientation property to the desired degrees of rotation. – Ken White May 03 '21 at 12:18