On Sun, 25 Apr 2010 18:44:30 +0300
Juha Manninen <[email protected]> wrote:

> Hi
> 
> Is this FPC behavior correct?
> Apparently it works in Delphi, at least ESS Model prog uses it heavily.
> 
> The idea is to typecast controls like TForm and TTreeView to a local 
> TCrackControl just to reach the protected TControl.OnMouseDown.
> 
>   type
>     TCrackControl = class(TControl) end;  // <-- empty local class
>   var
>     found: TControl;
>     cc: TCrackControl;
> 
> and later:
>   // 'found' can be TForm or anything.
>   cc:=TCrackControl(found);  // <-- error
>   cc.OnMouseDown(...
> 
> In Lazarus / FPC it gives 'RunError(219)', or the system becomes unstable.
> (I think this created the previous problem instead of interfaces).
> 
> The typecast should logically work because the controls inherit from TControl 
> and OnMouseDown is defined there.

This trick is used at a few places in the Lazarus code for normal
classes. I don't know if this works with interfaced classes.


Mattias

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to