Board index » delphi » User-Defined Types in Event-Interface

User-Defined Types in Event-Interface

I created a Automation-Object with Event-Support.
In this Event-Interface I want to use user-defined types.

Following example shows the problem.

My user-Type is defined in the Type-Library-Editor as followed
TJobStruct = record
  [ uuid '{937BF3F4-F0DA-11D2-B98C-00104B736D85}',
    version 1.0 ]
  JobId: Integer;
  MeasureProgramId: Integer;
  StartTime: TDateTime;
  EndTime: TDateTime;
  MesureStateId: Integer;
  JobPriorityId: Integer;
  DistributionByDayTimeId: Integer;
end;

In the Type-Library-Editor the Event-Handler is defined as followed:

  procedure OnChangeJob(Job: TJobStruct) [dispid $00000004]; stdcall;

but in the TLB-File the definition looks like that:

  procedure OnChangeJob(Job: {??TJobStruct} OleVariant); dispid 4;

Is the use of user-Defined Types in the Event-Interface possible?
If possible:
How can I fill this OleVariant with the data of my Type?
How can I get the data of my Type in the client?
(I use Delphi Event-Sink Generator which was developed by Developed by Binh
Ly
to get a component for the Events)

Thanks for help

 

Re:User-Defined Types in Event-Interface


The type library editor is a bit flaky in handling this type of thing and it
will simply force olevariant on you. Since all your fields in your stucture
are simple types, you can pack (and unpack) the entire structure as an
olevariant (use the VarArrayCreate, VarArrayLock, and VarArrayUnlock
routines) and pass it between client and server.

have fun
--
Binh Ly
Brickhouse Data Systems, Inc
http://www.brickhouse.com

Quote
Bernhard Geyer wrote in message <7et3bd$bc...@forums.borland.com>...
>I created a Automation-Object with Event-Support.
>In this Event-Interface I want to use user-defined types.

>Following example shows the problem.

>My user-Type is defined in the Type-Library-Editor as followed
>TJobStruct = record
>  [ uuid '{937BF3F4-F0DA-11D2-B98C-00104B736D85}',
>    version 1.0 ]
>  JobId: Integer;
>  MeasureProgramId: Integer;
>  StartTime: TDateTime;
>  EndTime: TDateTime;
>  MesureStateId: Integer;
>  JobPriorityId: Integer;
>  DistributionByDayTimeId: Integer;
>end;

>In the Type-Library-Editor the Event-Handler is defined as followed:

>  procedure OnChangeJob(Job: TJobStruct) [dispid $00000004]; stdcall;

>but in the TLB-File the definition looks like that:

>  procedure OnChangeJob(Job: {??TJobStruct} OleVariant); dispid 4;

>Is the use of user-Defined Types in the Event-Interface possible?
>If possible:
>How can I fill this OleVariant with the data of my Type?
>How can I get the data of my Type in the client?
>(I use Delphi Event-Sink Generator which was developed by Developed by Binh
>Ly
>to get a component for the Events)

>Thanks for help

Other Threads