Re: Delphi 5 server app as a dll without forms



On Jan 15, 4:53 pm, "Rudy Velthuis" <newsgro...@xxxxxxxxxxxx> wrote:
gforce wrote:
I'm guessing to create an OnTimer event for a Timer object would
be Timer.OnTimer := <procedure name>???

Almost. <method name>. The difference is important.
Right, because a method has a return value right?

Wrong. A method is a class member (can be a function or a procedure), a
mere procedure is not.

  Timer.OnTimer := <instance name>.<method name>

assigns TWO (2) things to OnTimer: the address of the instance and the
address of the code of the method. You can omit "<instance name>." but
that means the instance is Self, and that is the Data value assigned to
OnTimer.

Under the syntactic cover, OnTimer, of type TNotifyEvent, just like any
other event, is stored as a TMethod type, which has two Pointer fields:
Data and Code. Data points to the instance, Code to the code of the
method. The big difference with a normal procedural pointer is that the
instance is also stored (and used). This is very important in the case
of events.
--
Rudy Velthuis        http://rvelthuis.de

"The first half of our life is ruined by our parents and the
 second half by our children." -- Clarence Darrow.

If you don't mind I ask another question about this. I've read all
over and it seems that you are indicating the same thing that I've
read which is the method used for the OnEvent needs to be in a class.
Is there anyway around this? Since I'm working outside of a form I
don't have a parent object. I just have a procedure. This kind of
gets back to needing a form, it seems that everything is tailored
around forms and to get things to work without a form tends to require
working around the default environment. Of course, having a form in a
dll environment is also complicated, since than you have to manually
instantiate it.

The person hiring me to do this loves Delphi Pascal because of it's
form approach to programming and suggest that I just have an invisible
form but he hasn't made a dll with Delphi Pascal. To me it seems like
the wrong approach.

I've tried putting everything into a class however, you can't export a
class. It seems that I'm going to have to put all my objects that I
want to use OnEvent methods for are going to have to be in a class and
than I will have to expose a few procedures to export. Is that the
right track?

Thanks for all the great help by the way.

George
.