[ Pobierz całość w formacie PDF ]
.4 Property categoriesCategory PurposeTActionCategory Properties related to runtime actions; the Enabled and Hint properties ofTEdit are in this category.TDatabaseCategory Properties related to database operations; the DatabaseName and SQLproperties of TQuery are in this category.TDragNDropCategory Properties related to drag-n-drop and docking operations; theDragCursor and DragKind properties of TImage are in this category.THelpCategory Properties related to using online help or hints; the HelpContext and Hintproperties of TMemo are in this category.TLayoutCategory Properties related to the visual display of a control at design-time; theTop and Left properties of TDBEdit are in this category.TLegacyCategory Properties related to obsolete operations; the Ctl3D and ParentCtl3Dproperties of TComboBox are in this category.TLinkageCategory Properties related to associating or linking one component to another;the DataSet property of TDataSource is in this category.TLocaleCategory Properties related to international locales; the BiDiMode andParentBiDiMode properties of TMainMenu are in this category.TLocalizableCategory Properties that may require modification in localized versions of anapplication.Many string properties (such as Caption) are in thiscategory, as are properties that determine the size and position ofcontrols.Maki ng c omponent s av ai l abl e at des i gn t i me 46-17 Pr o p e r t y c a t e g o r i e sTable 46.4 Property categories (continued)Category PurposeTMiscellaneousCategory Properties that do not fit a category or do not need to be categorized(and properties not explicitly registered to a specific category); theAllowAllUp and Name properties of TSpeedButton are in this category.TVisualCategory Properties related to the visual display of a control at runtime; the Alignand Visible properties of TScrollBox are in this category.TInputCategory Properties related to the input of data (need not be related to databaseoperations); the Enabled and ReadOnly properties of TEdit are in thiscategory.Deriving new property categoriesYou can create new property categories of your own design by deriving a class fromeither the base class TPropertyCategory or one of the built-in descendants.See thesection  Property category classes on page 46-17 for a list of the available propertycategories and a brief description of their uses.When deriving a new property category class, override the Name method.The Namemethod provides the name of the category for display in the Object Inspector.Thismethod must be superseded with a method that returns the name of the customcategory.The Name method may simply return an AnsiString value or it may retrievea value from a resource.The latter is useful for easily internationalizing a customcomponent and its categories.Given the new Name method below for a custom category class, the text  My Specialwould appear in the Object Inspector when property categories are displayed (and atleast one of the current object s properties is registered in this property class).Using the IsPropertyInCategory functionAn application can query the existing registered properties to determine whether agiven property is already registered in a specified category.This can be especiallyuseful in situations like a localization utility that checks the categorization ofproperties preparatory to performing its localization operations.Two overloadedvariations of the IsPropertyInCategory function are available, allowing for differentcriteria in determining whether a property is in a category.The first variation allows you to base the comparison criteria on a combination of theclass type of the owning component and the property s name.In the command linebelow, for IsPropertyInCategory to return true, the property must belong to the classTEdit, have the name  Text , and be in the property category TLocalizableCategory.The second variation allows you to base the comparison criteria on a combination ofthe class name of the owning component and the property s name.In the commandline below, for IsPropertyInCategory to return true, the property must belong to theclass TEdit, have the name  Text , and be in the property categoryTLocalizableCategory.46-18 Dev el oper  s Gui de Co mp i l i n g c o mp o n e n t s i n t o p a c k a g e sCompiling components into packagesOnce your components are registered, you must compile them as packages beforethey can be installed in the IDE.A package can contain one or several components aswell as custom property editors.For more information about packages, seeChapter 10,  Working with packages and components.To create and compile a package, see  Creating and editing packages on page 10-6.Put the source-code units for your custom components in the package s Contains list.If your components depend on other packages, include those packages in theRequires list.To install your components in the IDE, see  Installing component packages onpage 10-5.Troubleshooting custom componentsA common problem when registering and installing custom components is that thecomponent does not show up in the list of components after the package issuccessfully installed.The most common causes for component not showing up in the list or on the palette:" Missing PACKAGE modifier on the Register function" Missing PACKAGE modifier on the class" Missing #pragma package(smart_init) in the C++ source file" Register function is not found in a namespace with the same name as the sourcecode module name." Register is not being successfully exported.Use tdump on the.BPL to look for theexported function:tdump -ebpl mypack.bpl mypack.dmpIn the exports section of the dump, you should see the Register function (withinthe namespace) being exported.Maki ng c omponent s av ai l abl e at des i gn t i me 46-19 46-20 Dev el oper  s Gui de Ch a p t e r47Chapter47Modifying an existing componentThe easiest way to create a component is to derive it from a component that doesnearly everything you want, then make whatever changes you need.The example inthis chapter modifies the standard memo component to create a memo that has ayellow background.The other chapters in this part describe creating more complexcomponents.The basic process is always the same, but more complex componentsrequire more steps in customizing the new class.Modifying an existing component takes only two steps:" Creating and registering the component" Modifying the component classCreating and registering the componentCreation of every component begins the same way: you create a unit, derive acomponent class, register it, and install it on the Component palette.This process isoutlined in  Creating a new component on page 39-7.For this example, follow the general procedure for creating a component, with thesespecifics:1 Name the component s unit YelMemo and save it, so that the header file isYELMEMO.H and the.CPP file is YELMEMO.CPP.2 Derive a new component class called TYellowMemo, descended from TMemo.3 Register TYellowMemo on the Samples page of the Component palette [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • rozszczep.opx.pl
  •