Saturday, January 16, 2010

What is custom control and how to create it?

A custom control is a control that a third party (you) develops to include in programs that is not part of the ';standard'; set of components that come with your development tool of choice. There are two types of controls: visual and non-visual. Visual controls include edit boxes, buttons, list boxes, tree views, etc. Non-visual controls include componets without a visual aspect such as data sets, communication protocols, timers, etc.





I have only written custom controls for Delphi. In Delphi there is a new compontent wizard. To create a non-visual component, inherit from TComponent. To create a visual component, either inherit from an existing component that provides most of the functionality you need, or derive from TWinControl. You will then need to override the painting methods of the component to draw your component to the screen. All published properties will end up being displayed in the Object Inspector. If you're using Delphi, look at the VCL source code. All of the source code for the components on the component toolbar is included and are excellent examples of how to accomplish certain features.





I have just started playing with C# components. Once I get those down, I can give you more information on them.

No comments:

Post a Comment