[lazarus] Calling a class method by pointer
Michael A. Hess
mhess at miraclec.com
Sun May 16 16:26:52 EDT 1999
Greetings,
Should I be able to call a class method by passing a pointer to that
method and then running the method by referencing the pointer.
The following is a crude layout and not meant to be compiled and tested.
type
TMyClass = class(some parent)
.
.
procedure Stuff;
procedure Setup;
end;
TProcedure = procedure;
procedure PlainProcedure;
begin
... does stuff
end;
procedure TMyClass.Stuff;
begin
... does stuff
end;
procedure TMyClass.Setup;
var
proc : Pointer;
begin
proc := @PlainProcedure;
// now try and call the plain procedure
TProcedure(proc);
// This works, does stuff, and returns correctly.
proc := @Stuff;
// now try and call the class procedure
TProcedure(proc);
// it called Stuff and did whatever was in it but gives an
// access violation when it attempts to return.
end;
Should the above type of scenerio, calling a class method by pointer, be
able to work or am I trying to do something that is normally illegal?
--
==== Programming my first best destiny! ====
Michael A. Hess Miracle Concepts, Inc.
mhess at miraclec.com http://www.miraclec.com
More information about the Lazarus
mailing list