How to Add Properties to a Data Module?

   

As with all forms, data modules do not easily allow the addition of published properties. The best method for getting around this problem is to create a special TComponent descendant with published properties that are the ones you would add to the data module if you could. Such a component can then be manipulated, and its property values set at design time or runtime. The component can be accessed by the code in data module event handlers during program operation, or by forms that need to make values (including pointers to controls) available to the data module without having the data module be coupled to a specific form.

Naturally, you can also use public methods , variables , or properties, but then you will be limited to setting values at runtime. This is more error prone and more difficult to verify because you cannot look at the component alone, but must also read the associated C++ statements in the .cpp file that uses the component. Nevertheless, such methods have a place. For instance, you can have a user interface that needs to register a control, such as a progress bar, with the data module. This cannot be done at design time without coupling the data module to the form, so it must be done by setting a public variable or property in your C++ code.


   
Top


C++ Builder Developers Guide
C++Builder 5 Developers Guide
ISBN: 0672319721
EAN: 2147483647
Year: 2002
Pages: 253

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net