Hello,
You should cast to TWindowClass as TWindow is used to cast an instance,
not a class reference.
Note that you may not have TWindowClass, in which case you need to
declare it like this:
type
TWindowClass = class of TWindow;
Note that CreateNewWindow would have to be virtual for derived clases
methods to be called.
Le 01/05/2024 à 16꞉28, Adriaan van Os via fpc-pascal a écrit :
Suppose I have a
var myClass: TClass
and (for example) a
class function TWindow.CreateNewWindow( ....)
Now I want to call CreateNewWindow for var myClass. Of course,
depending on the class, CreateNewWindow will behave different.
Type-casting myClass to TWindow crashes (in my setup). And even if it
worked, wouldn't it loose the class information ?
Of course, by adding an extra parameter of type TClass to
CreateNewWindow, the issue can be solved. But that's far from elegant.
How to solve this ? Anything I missed ?
Regards,
Adriaan van Os
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal