

Published section of a component's declaration, it also appears in Returned value to something different from the type of the storage field toĪnother fundamental reason for the use of properties is to make modificationsĪvailable to them during design time. A reader access method, for example, can change the type of the Implementation of the field access without affecting the behavior for theĬomponent user. One key advantage to providing access to a component's internal storageįields through properties is that the component writer can change the Side effects can be much more sophisticated than this. TCustomEdit, the side effect is that the encapsulated edit control is



In assigning a value to the MaxLength property of Side effects are any actions affected by the assignment of a value to a Side effect when assigning property values. SendMessage() in the property's writer access method is known as a Limits the amount of text that a user can enter into an edit control. Message to the window that TCustomEdit encapsulates.
COMPONENT DRAWING SEARCH DELPHI WINDOWS
The SendMessage() function to pass the EM_LIMITTEXT Windows The assignment to the internal storage field FMaxLength and then calls This method first verifies that the component user isn't attempting toĪssign the same value as that which the property already holds. If HandleAllocated then SendMessage(Handle, EM_LIMITTEXT, Value, 0) Method: procedure TCustomEdit.SetMaxLength(Value: Integer) ForĮxample, examine the implementation of the following SetMaxLength() The method layer to assign values is to protect the storage field from receivingĮrroneous data as well as to perform various side effects, if required. The internal storage field to which the property refers. Purpose of the writer access method is to assign the value of the parameter to The reader access method GetMaxLength() would be declared asįollows: function GetMaxLength: Integer Property Access MethodsĪccess methods take a single parameter of the same type as the property. Would be declared as follows: property MaxLength: Integer read GetMaxLength write SetMaxLength default 0 A property can alsoĬontain a reader access method, in which case the MaxLength property MaxLength, the writer access method SetMaxLength() is used toĪssign the value to the storage field FMaxLength. Method by which the storage fields are assigned values. MaxLength property directly reads the value from theįMaxLength storage field. The readĭeclaration specifies how the component's storage fields are read. Name, the property type, a read declaration, a writeĭeclaration, and an optional default value. The parts of a property definition consist of the property The property MaxLength is the access to the storage fieldįMaxLength. Property MaxLength: Integer read FMaxLength write SetMaxLength default 0 Property definition: TCustomEdit = class(TWinControl) Properties provide access to storage fields either by accessing the storageįields directly or through access methods. Typically, the user doesn't have direct access to component storageįields because they're declared in the private section of aĬomponent's class definition. Using properties, the component user can modify or read storage field Properties give the user an interface to a component's internal storageįields. This article discusses the makeup of Delphi components. Components are Object Pascal classes that encapsulate theįunctionality and behavior of elements developers use to add visual andīehavioral characteristics to their programs.
