You create every component in the same way: create a unit, derive a component class, register it, compile it, and install it on the Tool palette. This process is outlined in Creating a new component.
unit Shapes; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms; type TSampleShape = class(TGraphicControl) end; procedure Register; implementation procedure Register; begin RegisterComponent('Samples', [TSampleShape]); end; end.
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Shapes.h" //--------------------------------------------------------------------------- #pragma package(smart_init); //--------------------------------------------------------------------------- // ValidCtrCheck is used to assure that the components created do not have // any pure virtual functions. // static inline void ValidCtrCheck(TSampleShape *) { new TSampleShape(NULL); } //--------------------------------------------------------------------------- __fastcall TSampleShape::TGraphicControl(TComponent* Owner) : TGraphicControl(Owner) { } //--------------------------------------------------------------------------- namespace Shapes { void __fastcall PACKAGE Register() { TComponentClass classes[1] = {__classid(TSampleShape)}; RegisterComponents("Samples", classes, 0); } }
//--------------------------------------------------------------------------- #ifndef ShapesH #define ShapesH //--------------------------------------------------------------------------- #include <sysutils.hpp> #include <controls.hpp> #include <classes.hpp> #include <forms.hpp> //--------------------------------------------------------------------------- class PACKAGE TSampleShape : public TGraphicControl { private: protected: public: __published: }; //--------------------------------------------------------------------------- #endif
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|