Method (methods)
The methods in VCL are functions and procedures. Calling these functions and procedures allows the component to complete certain actions. For example, all visualization components have a method called show, which is used to display components. Another method is hide, which is used to hide components. For example:
MyWindow.Show;{ do something ...}MyWindow.Hide;
The VCL method can be declared as public, protected, and private. The public method can be accessed by component users. In this example, both the hide and show methods are public. The protected method cannot be used by the component user, but it can be used to access the derived class of the component. Of course, the private method can only be accessed by the class itself.
Some methods have parameters and return values, while others do not. This fully depends on how component writers compile this method. For example, the gettextbuf method can be used to retrieve the text of the tedit component. This method can be used to retrieve the text from the tedit component. The specific code is as follows:
var Buff: array[0..255] of Char; NumChars: Integer;begin NumChars := Edit1.GetTextBuf(Buff, SizeOf(Buff));end;
The gettextbuf method shown above has two parameters and returns an integer. When this method is called, the content in the tedit component is placed in the buff variable, the returned value is the number of characters retrieved from the tedit component.
Method rules
- Methods can be public, protected, and private;
- Key operators of calling methods;
- The method can contain parameters and return values;
- Some methods do not include parameters and do not return values;
- Only public methods can be used by users who have components.