I'm writing a simple program in Delphi7 that uses a unit written by someone else (IB TWS API 9.71), and I can't handle passing values from that unit to my program. In the opposite direction, everything works without problems. Here is a piece of Unity code:
unit TWSLib_TLB;
const
LIBID_TWSLib: TGUID = '{0A77CCF5-052C-11D6-B0EC-00B0D074179C}';
DIID__DTws: TGUID = '{0A77CCF6-052C-11D6-B0EC-00B0D074179C}';
DIID__DTwsEvents: TGUID = '{0A77CCF7-052C-11D6-B0EC-00B0D074179C}';
CLASS_Tws: TGUID = '{0A77CCF8-052C-11D6-B0EC-00B0D074179C}';
type
_DTwsEvents = dispinterface;
// DispIntf: _DTwsEvents
// Flags: (4096) Dispatchable
// GUID: {0A77CCF7-052C-11D6-B0EC-00B0D074179C}
// *********************************************************************//
_DTwsEvents = dispinterface
procedure currentTime(time: Integer); dispid 32;
// OLE Control Proxy class declaration
// Control Name : TTws
// Help String : Tws Control
// Default Interface: _DTws
// Def. Intf. DISP? : Yes
// Event Interface: _DTwsEvents
// TypeFlags : (34) CanCreate Control
TTwscurrentTime = procedure(ASender: TObject; time: Integer) of object;
Here is a piece of code in my program:
procedure TForm1.Connect_TWSClick(Sender: TObject);
var
Disp:IDispatch;
Event:_DTwsEvents;
begin
Tws1.connect('127.0.0.1', 7496, 0, 0);
Disp:=CreateComObject(CLASS_Tws) as IDispatch;
Event:=_DTwsEvents(Disp);
time:=1;
Tws1.reqCurrentTime;
Event.currentTime(time); //in "time" should be the current time, but it is not
This is written in manual of unit: "ActiveX events receive information from the system and make it available to an application. This section defines the ActiveX events you can receive via the DTwsEvents interface." And specifically for the currentTime procedure: "This method receives the current system time on the server side." Can someone please point me in the direction of where I am going wrong? Thank you.