Recent

Author Topic: Design time support for TCustomDesignControl descendants  (Read 1095 times)

Alex.Machado

  • New Member
  • *
  • Posts: 35
Design time support for TCustomDesignControl descendants
« on: February 11, 2024, 01:22:50 am »
Hi all,

I'm finishing porting a component library from Delphi to Lazarus and I'm hitting a wall and I think I'm missing something... I hope someone can point me to the right direction.

In my Delphi codebase i have a TScrollingWinControl descendant that, at design time, should behave as a TFrame (i.e. it would be able to receive visual controls). I can't descend it from TFrame/TCustomFrame though (and this can't be changed).
When converting the code base to Lazarus/FPC I used TCustomDesignControl instead of TScrollingWinControl (exactly the same as a TCustomFrame does). At runtime everything works as it should and I don't see any issues. So far so good.

However, at design time it doesn't behave as expected. I can drop visual controls onto this new TFrame-like container, but the controls don't paint themselves and can't be moved around (I can only resize them). I would expect my TCustomDesignControl to behave at design time similarly to a TFrame (regarding parented/owned visual controls), but it doesn't.

I read all TCustomFrame related code and I also implemented things that could possibly be required:

I implemented an overriden class procedure WSRegisterClass, and from it I'm calling the RegisterCustomFrame proc. I also implemented the GetChildren(), identical to the TCustomFrame implmentation. Still, nothing changed.

So, my question is: how to add the missing design time support to my TCustomDesignControl without changing the ancestor to a TCustomFrame/TCustomForm?

Thanks in advance
« Last Edit: February 11, 2024, 01:24:22 am by Alex.Machado »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4541
  • I like bugs.
Re: Design time support for TCustomDesignControl descendants
« Reply #1 on: February 11, 2024, 06:55:57 am »
I guess it is a limitation in the form designer although I didn't study it now.
Maybe it should be modified to support TCustomDesignControl.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Alex.Machado

  • New Member
  • *
  • Posts: 35
Re: Design time support for TCustomDesignControl descendants
« Reply #2 on: February 11, 2024, 08:32:02 pm »
Thanks for your answer.

As I understand it, you're basically saying that the form designer won't support anything other than TCustomForm and TCustomFrame descendants? If that's the case, this is bad...

Alex.Machado

  • New Member
  • *
  • Posts: 35
Re: Design time support for TCustomDesignControl descendants
« Reply #3 on: February 11, 2024, 09:23:19 pm »
I believe one of the possible ways to deal with this is through subclassing TDesignerMediator and registering it. Not sure if it will work as expected before actually trying it out.

BTW, the TDesignerMediator idea is terrific and very useful for extending the IDE...
I just hoped that there was a simple way of telling the IDE to handle my TCustomDesignControl just like a TCustomFrame at design time.
« Last Edit: February 11, 2024, 09:33:18 pm by Alex.Machado »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4541
  • I like bugs.
Re: Design time support for TCustomDesignControl descendants
« Reply #4 on: February 12, 2024, 05:38:39 am »
You have studied the designer code! Indeed it can be extended with TDesignerMediator.
You must study some existing use case and try it. At least its author Mattias is there to help if problems arise.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

 

TinyPortal © 2005-2018