Interfaces and calling conventions
After I succeeded in using a homebrew Interface, I'm in doubt about the calling
convention. Obviously the default calling convention of the methods in the
interface is unimportant, at least if the interface is used only inside an
application.
But when I'm going to create COM interfaces, I think that the calling
convention *must* be 'stdcall'. Is this correct?
To explain my problem in depth:
I'm using D4 Standard, and have created an interface, that exposes some of the
TStrings methods and properties, and adds an OnChange event. The interface is
required, because I need a single data source object, that can be used in
several 'clients', but the 'server' object must never be destroyable by a
single 'client'. This requirement is fulfilled, since the interfaced object
determines by it's use-count, when to destroy itself.
One basic implementation of that interface is based on a TStringList, that
directly exposes a OnChange event. Therefore I simply delegate all interface
routines to that object, using Implements. This works well and with only a few
lines of code. But what changes will be required, when I want to use the
interface in other applications, using OLE? Since the calling conventin in the
TStringList isn't 'stdcall', I suspect that I must write wrappers for all items
in the interface declarations?
The next problem arises with a bare TStrings class, as exported by e.g. a
TListBox. The manipulation of the strings is no problem there, but how to
obtain an OnChange notification, when the TStrings object changes somehow? The
OnChange event is intended to make the TListBox visible as soon as it has
entries, and hide it if it doesn't contain anything, therefore it must watch
all Add, Clear etc. calls. Is it really necessary to create a descendant of the
TListBox, and catch all these calls, or can I use a single hook to e.g.
SetUpdateState, to catch all modifications?
DoDi