You create every component the same way: create a unit, derive a component class, register it, compile it, and install it on the Tool palette. Creating a new component.
unit CalSamp; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grids; type TSampleCalendar = class(TCustomGrid) end; procedure Register; implementation procedure Register; begin RegisterComponents('Samples', [TSampleCalendar]); end; end.
#include <vcl\vcl.h> #pragma hdrstop #include "CalSamp.h" //--------------------------------------------------------------------------- #pragma package(smart_init); //--------------------------------------------------------------------------- static inline TSampleCalendar *ValidCtrCheck() { return new TSampleCalendar(NULL); } //--------------------------------------------------------------------------- namespace Calsamp { void __fastcall PACKAGE Register() { TComponentClass classes[1] = {__classid(TSampleCalendar)}; RegisterComponents("Samples", classes, 0); //Use a different page in CLX applications } }
#ifndef CalSampH #define CalSampH //--------------------------------------------------------------------------- #include <vcl\sysutils.hpp> #include <vcl\controls.hpp> #include <vcl\classes.hpp> #include <vcl\forms.hpp> #include <vcl\grids.hpp> //--------------------------------------------------------------------------- class PACKAGE TSampleCalendar : public TCustomGrid { private: protected: public: __published: }; //--------------------------------------------------------------------------- #endif
If you install the calendar component now, you will find that it appears on the Samples category. The only properties available are the most basic control properties. The next step is to make some of the more specialized properties available to users of the calendar.
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|