Re: [DUG]: Fproc

1999-03-21 Thread Nic Wise

Does the callback not need a parameter or 3? The stack will be all over
the place
if it does...

99% of windows callbacks atleast take a hWND and return an integer.

Nic.


Alistair George wrote:
 
 A while ago, Nic kindly came up with an answer to my query about a callback
 proceedure. Well today I implimented the procs as below.
 The callback works, but it causes an access violation error, and that is
 with NOTHING being done in the callback proc at all - it should just go
 there and return. But in going to the call (and it does reach it) and
 returning, there is some violation.
 Could it be that stdcall is expecting something to be returned??
 the docs say that Stdcall is a function, but recommend using it.
 Any suggestions appreciated.
 Tks,
 Al+
  Type TMyClass = class
procedure mycallback;
  end;
 
  var
myclass : TMyClass;
 
  implementation
 
  procedure TMyClass.myCallBack;
  begin
//do whatever - you need to add params no doubt.
  end;
 
  procedure CallBack;stdcall;
  begin
myClass.myCallBack; //just throw it into the object for more
  processing
  //you could do it all here, tho
  end;
 
  initilization
myClass := TMyClass.Create;
  end.
 
 ---
 New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
   Website: http://www.delphi.org.nz

-- 
Nic Wise - Inprise New Zealand Ltd. [EMAIL PROTECTED] 
09-360-0231 (wk), 021-676-418 (mob), [EMAIL PROTECTED] (hm)
My opinions do not reflect the opinions of my employer,
or myself at times.
---
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
  Website: http://www.delphi.org.nz



Re: [DUG]: Fproc

1999-03-18 Thread Nic Wise


 I need to set a callback function with a Windows call, but cant figure out
 how to point to a function in my program. For example
 Callback(hwnd, fpProc);
 Where fpProc is Address of the callback function.
 
 Say my function in current proceedure is
 Tmainform.beeper:boolean;
 begin
 end;
 
 Callback(hwnd,Longint(@beeper)); Does not work.

OK, first beeper is a method, not a function/procedure, and as much it
gets
a reference to your object pushed onto the stack before its called.

You need to do something like:

function beeper : boolean;
begin
  return myMainFormVar.beeper;
end;

etc..

Nic.
---
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
  Website: http://www.delphi.org.nz