Holger's Thoughts on Delphi

Sunday, November 20, 2005

Indy and Winforms (using GExperts)

I had an interesting chat today about a topic that's been an issue for Indy in the last couple of months. Firstly, let me say that the Indy Library does not have any dependencies on the Delphi RTL any longer. The Indy Core Team implemented custom RTL routines, so we no longer depend on the Borland-Namespace.

However, a lot of people still are surprised that you can do Winforms development with Indy. Why shouldn't you? All Indy stuff for .NET are assemblies, no different from any other 3rd party assembly. The only difference is the design-time support. VCL.NET does have design-time support, Winforms does not.

Just in case: Design-time support means that the components appear on the Tool Palette, you can drop them on a form and change properties during design-time. In Winforms we do currently not have that capability.

There are many reasons for this, but the most striking one is that the property editors which we have for VCL would have to be completely rewritten for Winforms, for which we currently do not have the manpower. We looked into it and decided to spend resources on other issues.

However, even if you do not want to write runtime code when using Indy components, I might have a workaround for you!

GExperts, a 'couple' ( of wonderful IDE plugins), helps you in that regard.


  1. create a VCL form,
  2. drop any Indy component on the form,
  3. set the properties to your liking,
  4. right-click the component and
  5. chose the command "Components to Code".

If you have an older version of GExperts you may find that item in the GExperts menu. Thus, you will end-up with the code to create that exact component in the clipboard. The final step is to paste that code into your Winforms application.

Here you see the popup menu with the GExpert item "Components to Code"

This generates the following source code:

Of course, this does not help you at all when using C#. I am very aware of that. However, as I was talking in the chat today I thought that more people could profit of the result of that chat.


  • I recall looking at the design time myself and I recall it a bit differently. Making a GUI is not the big problem (a lot of that has been done). The big problem is that in DotNET, design-time behaviors in the IDE such as component editors and icons are defined with attributes in the run-time package (I don't recall the exact syntax but in Delphi, you can only do it with the NET personality). One fix I had made was to embed an attribute in the TIdBaseComponent definition to prevent Indy classes from appearing in the WinForms IDE and I did that because every Indy class was showing up in that IDE (no matter if it was meant simply as an abstract component).


    About the way I could see us ever doing such a thing is to put all sorts of IFDEF's in a lot of units just to embed the design-time attributes and Kudzu did not approve of that. He did mention another way of doing things but that's a cludge.

    In this case, you can't have your cake and eat it too.

    By Anonymous Anonymous, at 8:01 PM  

Post a Comment

<< Home