[fpc-pascal] String message methods and the self parameter
Sven Barth
pascaldragon at googlemail.com
Sat Jan 6 17:35:21 CET 2018
Am 06.01.2018 17:25 schrieb "Ewald" <ewald at yellowcouch.org>:
Hi,
When reading https://www.freepascal.org/docs-html/ref/refsu31.html#
x82-1040006.5.7 I stumbled on the following text at the bottom of the page:
"In addition to this mechanism, a string message method accepts a self
parameter:
Procedure StrMsgHandler(Data: Pointer;
Self: TMyObject); Message ’OnClick’;
When encountering such a method, the compiler will generate code that loads
the Self parameter into the object instance pointer. The result of this is
that it is possible to pass Self as a parameter to such a method.
Remark: The type of the Self parameter must be of the same class as the
class the method is defined in."
1. This code snippet fails to compile with the message "Message handlers
can take only one call by ref. parameter" (revision 30487, $mode objfpc)
2. "[...] When encountering such a method, [...]": What are the exact
criteria: the parameter name, the parameter type, ...?
3. Can anybody explain what the part "The result of this is that it is
possible to pass Self as a parameter to such a method." entails? How can it
be passed with DispatchStr?
4. Can somebody give an example on how to use this functionality?
Judging from the implementation inside the RTL I'd say that this is a bug
in the documentation. String message methods work like ordinal ones and
take only one parameter.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180106/700ce32b/attachment.html>
More information about the fpc-pascal
mailing list