[fpc-devel] procedure Types
Geno Roupsky
groupsky at gmail.com
Wed Mar 15 17:49:22 CET 2006
You could use this:
[snip]
type
TObjThreadFunc = function: PtrInt of object;
function BeginObjThread(ThreadFunction: TObjThreadFunc): DWord;
begin
with TMethod(ThreadFunction) do
Result := BeginThread(TThreadFunc(Code), Data);
end;
[/snip]
2006/3/13, Amir Aavani <Aavani at iust.ac.ir>:
>
> Any idea to call:
> BeginThread (@MyObject.F1, Pointer (S))
>
> Michael Van Canneyt wrote:
>
> >On Sat, 4 Mar 2006, Amir Aavani wrote:
> >
> >
> >
> >>I have problem with procedure Types.
> >>Look at the following code:
> >>
> >>TProcedure= procedure (S: String);
> >>TTest= class
> >>MyF: TProcedure;
> >>procedure F1 (S: String);
> >>procedure F2 (S: String);
> >>....
> >>...
> >>end;
> >>
> >>TTest.constructor ;
> >>begin
> >> MyF:= @F1;
> >>end;
> >>
> >>it says it can't cast "Procedure (S: String); Object" to TProcedure. The
> >>problem is clear but I don't know
> >>(can't find) any solution to define TProcedure as a procedure of a class which
> >>accepts one argument.
> >>
> >>
> >
> >Try the following (note the 'of object' in the declaration):
> >
> >Type
> > TMyStringProc = procedure (S : String) of object;
> >
> >and then
> >x
> > MyF : TMyStringProc;
> >
> >This is documented.
> >
> >Michael.
> >_______________________________________________
> >fpc-devel maillist - fpc-devel at lists.freepascal.org
> >http://lists.freepascal.org/mailman/listinfo/fpc-devel
> >
> >
>
>
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>
--
Geno Roupsky
More information about the fpc-devel
mailing list