Friday, October 21, 2011

Delphi Custom Control Panel (Explode\Collapse)



Delphi is still a language and an environment valid to use, it is a like David against Golia, where Golia is Visual Studio. I’m still working with Delphi 2010 and to be honest has many lacks that VS has not, but on the other hand it is very efficient.

I was in the past a supporter of standard component and every time I had necessity of one I have developed it. Today it is different because there are too many companies that work to develop components, so maybe, it is not stupid to think about buying these.

By the way, I’m not here to talk about Delphi but to document how to realize a custom component like an "Explode\Collapse Panel". The idea is to group homogenous information (controls) inside these panels, to display in a user window. The main function should be activable by button on top left corner of panel that will collapse and expand the area and also it should drag an attached panel.


Here the property of this component:
Events:

GrtOnExpand: TNotifyEvent;
It is fired when the area is expanded
GrtOnCollapse: TNotifyEvent;
It is fired when the area is collapsed
Properties

GrtCaption: string;
Control Caption
GrtHeight: ineteger;
Control Height when expanded
GrtAttachedPanel: TPanel;
Control Panel attached. It is repositioned when the status of the control change.
GrtAutoCollapse: boolean;
The control is resized automatically.
GrtStatus: TEnumExpandStatus;
Control status (expanded or collapsed)
GrtBtnImage: TBitmap;
Button Image

Many improvements can be done, this is a base object.

A sample of improved panel

Exploded Panels on that application

download source code