views:

456

answers:

3

I'd like to create a custom "datamodule" in Delphi, a TDataModule like (maybe inherited) class which would have a custom grid based design interface (one component per line, some properties as columns). Is this possible? Where should I start?

I'm currently using Delphi 2007.

A: 

It's not possible exactly as you describe it. You can't place visual components like a grid on a data module. You need a form or frame for that.

If I were to do try to something like you're describing, I'd use a list box to hold a list of individual components, a couple buttons and a selection dialog box for adding and deleting components from the list, and the TJvInspector component from the JVCL for modifying properties. That would be a lot easier than trying to make a one-size-fits-all grid to handle the situation.

Mason Wheeler
I'm not thinking visual components, but TDataModule replacement for non-visual components.I think I can handle the user interface part of the problem, but I've no idea how to integrate such thing with Delphi so that I can create TMyOwnDataModule in design time and add new components.
Harriv
+1  A: 

As Nick Hodges pointer out here:

http://stackoverflow.com/questions/1056472/drawing-on-a-datamodule-in-delphi

it would be difficult to paint on the TDataModule descendant. Not impossible probably, but not worth the trouble for sure.

I would consider designing a completely new TDataModule from scratch, so you would have complete control over it. Sure a lot of work probably, but in the end it would pay off.

You can find TDataModule class in the Classes.pas unit. But this is just the runtime part of the code. Other parts are IDE related. You can find units related to ToolsAPI in "c:\Program Files\Borland\BDS\4.0\source\ToolsAPI\" for BDS 2006 for instance. You can also derive you own data module from TDataModule and register it with RegisterCustomModule (DesignIntf.pas). I don't know much more on this subject, maybe others do. As I said it would not be easy to do something like that. But maybe with this initial information you can find what you want.

Runner
Nick was talking about drawing a background for a TDataModule at design time. A data module is a non-visual control. You can't get it to show up at runtime.
Mason Wheeler
Do you have any pointers how to design completely new TDataModule? I think that the source code for current TDataModule designer is not available.
Harriv
I updated the answer with what I know on the subject
Runner
+1  A: 

Maybe it is possible. An example of a XML Frame Designer can be found on the page New IDE Building Blocks. Well this example is for Delphi 5, but it might be a good starting point.

Uwe Schuster
Thank, that get's me on right track I hope, althought the content is pretty incomplete.
Harriv