<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Hello,<br>
<br>
You should cast to TWindowClass as TWindow is used to cast an
instance, not a class reference.<br>
<br>
Note that you may not have TWindowClass, in which case you need to
declare it like this:<br>
<br>
type<br>
TWindowClass = class of TWindow;<br>
<br>
Note that CreateNewWindow would have to be virtual for derived
clases methods to be called.<br>
<br>
<br>
Le 01/05/2024 à 16꞉28, Adriaan van Os via fpc-pascal a écrit :<br>
</div>
<blockquote type="cite" cite="mid:6632517C.70902@adriaan.biz">Suppose
I have a
<br>
<br>
var myClass: TClass
<br>
<br>
and (for example) a
<br>
<br>
class function TWindow.CreateNewWindow( ....)
<br>
<br>
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 ?
<br>
<br>
Of course, by adding an extra parameter of type TClass to
CreateNewWindow, the issue can be solved. But that's far from
elegant.
<br>
<br>
How to solve this ? Anything I missed ?
<br>
<br>
Regards,
<br>
<br>
Adriaan van Os
<br>
<br>
_______________________________________________
<br>
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<br>
<a class="moz-txt-link-freetext" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>
<br>
</blockquote>
<br>
<div id="grammalecte_menu_main_button_shadow_host" style="width:
0px; height: 0px;"></div>
</body>
</html>