Board index » delphi » D5: Component wrapper for COM Object doesn't compile in a package

D5: Component wrapper for COM Object doesn't compile in a package

I've designed a Compoent wrapper called TJoystick that is a wrapper for the
DirectX 7.0 VB COM DirectInput objects.  The component compiles and works
just fine when I simply include it as a part of my project, but when I take
the component and add it to a package (so I can then make it available on
the component pallet) it always fails to compile and complains with the
error:

   Types of actual and formal var parameters must be identical

The line that it fails on is referencing the DeviceStateJoystick function of
a DirectInputDevice object.  The function is defined as:

    function  GetDeviceStateJoystick(var state: DIJOYSTATE): HResult;
stdcall;

When I call the function I pass it a variable that was defined as a
DIJOYSTATE, which is defined as the following in the type-library .pas file:

  DIJOYSTATE = packed record
    x: Integer;
    y: Integer;
    z: Integer;
    rx: Integer;
    ry: Integer;
    rz: Integer;
    slider: array[0..1] of Integer;
    POV: array[0..3] of Integer;
    buttons: array[0..31] of Byte;
  end;

What I don't understand is why my component will compile correctly when
included in a project and generates this error when compiled as part of a
package.

Anyone know what could be wrong?

Sincerely,

Wendell W. Pinegar

 

Re:D5: Component wrapper for COM Object doesn't compile in a package


Because when you compile it as part of the project, it knows how to deal
with TDIJOYSTATE.  *Always* use the T when you define your own types, helps
remind you what it is.  If you see a T in front of a var in a stdcall, you
can count on problems, since the marshalling will have to know how to deal
with this type.

COM is a Microsoft animal and does not know about Delphi types.  You'll need
to use OleVariant or one of the standard COM types in order for this to work
indepentenly.

HTH,

Brandon Smith

Wendell W. Pinegar <Wend...@thePinegars.com> wrote in message
news:8fkmqk$qbq2@bornews.borland.com...

Quote
> I've designed a Compoent wrapper called TJoystick that is a wrapper for
the
> DirectX 7.0 VB COM DirectInput objects.  The component compiles and works
> just fine when I simply include it as a part of my project, but when I
take
> the component and add it to a package (so I can then make it available on
> the component pallet) it always fails to compile and complains with the
> error:

>    Types of actual and formal var parameters must be identical

> The line that it fails on is referencing the DeviceStateJoystick function
of
> a DirectInputDevice object.  The function is defined as:

>     function  GetDeviceStateJoystick(var state: DIJOYSTATE): HResult;
> stdcall;

> When I call the function I pass it a variable that was defined as a
> DIJOYSTATE, which is defined as the following in the type-library .pas
file:

>   DIJOYSTATE = packed record
>     x: Integer;
>     y: Integer;
>     z: Integer;
>     rx: Integer;
>     ry: Integer;
>     rz: Integer;
>     slider: array[0..1] of Integer;
>     POV: array[0..3] of Integer;
>     buttons: array[0..31] of Byte;
>   end;

> What I don't understand is why my component will compile correctly when
> included in a project and generates this error when compiled as part of a
> package.

> Anyone know what could be wrong?

> Sincerely,

> Wendell W. Pinegar

Re:D5: Component wrapper for COM Object doesn't compile in a package


Brandon,

DIJOYSTATE is a record (data structure) and not a class object or COM
object.  It is defined and imported from the Microsoft DirectX 7.0 VB COM
type library and not a record that I created...it must be passed by
reference as a parameter to the COM DirectInputDevice.GetDeviceStateJoystick
method...so it doesn't make sense to me why it won't compile as part of a
package...

Does this additional information help?

"Brandon C. Smith" <Bran...@synature.com> wrote in message
news:8fmaqq$ble5@bornews.borland.com...

Quote
> Because when you compile it as part of the project, it knows how to deal
> with TDIJOYSTATE.  *Always* use the T when you define your own types,
helps
> remind you what it is.  If you see a T in front of a var in a stdcall, you
> can count on problems, since the marshalling will have to know how to deal
> with this type.

> COM is a Microsoft animal and does not know about Delphi types.  You'll
need
> to use OleVariant or one of the standard COM types in order for this to
work
> indepentenly.

> HTH,

> Brandon Smith

> Wendell W. Pinegar <Wend...@thePinegars.com> wrote in message
> news:8fkmqk$qbq2@bornews.borland.com...
> > I've designed a Compoent wrapper called TJoystick that is a wrapper for
> the
> > DirectX 7.0 VB COM DirectInput objects.  The component compiles and
works
> > just fine when I simply include it as a part of my project, but when I
> take
> > the component and add it to a package (so I can then make it available
on
> > the component pallet) it always fails to compile and complains with the
> > error:

> >    Types of actual and formal var parameters must be identical

> > The line that it fails on is referencing the DeviceStateJoystick
function
> of
> > a DirectInputDevice object.  The function is defined as:

> >     function  GetDeviceStateJoystick(var state: DIJOYSTATE): HResult;
> > stdcall;

> > When I call the function I pass it a variable that was defined as a
> > DIJOYSTATE, which is defined as the following in the type-library .pas
> file:

> >   DIJOYSTATE = packed record
> >     x: Integer;
> >     y: Integer;
> >     z: Integer;
> >     rx: Integer;
> >     ry: Integer;
> >     rz: Integer;
> >     slider: array[0..1] of Integer;
> >     POV: array[0..3] of Integer;
> >     buttons: array[0..31] of Byte;
> >   end;

> > What I don't understand is why my component will compile correctly when
> > included in a project and generates this error when compiled as part of
a
> > package.

> > Anyone know what could be wrong?

> > Sincerely,

> > Wendell W. Pinegar

Re:D5: Component wrapper for COM Object doesn't compile in a package


Does your package contain the _TLB.pas file generated when you imported the
type library?

Wendell W. Pinegar <Wend...@thePinegars.com> wrote in message
news:8fn9om$hqs4@bornews.borland.com...

Quote
> Brandon,

> DIJOYSTATE is a record (data structure) and not a class object or COM
> object.  It is defined and imported from the Microsoft DirectX 7.0 VB COM
> type library and not a record that I created...it must be passed by
> reference as a parameter to the COM

DirectInputDevice.GetDeviceStateJoystick
Quote
> method...so it doesn't make sense to me why it won't compile as part of a
> package...

> Does this additional information help?

> "Brandon C. Smith" <Bran...@synature.com> wrote in message
> news:8fmaqq$ble5@bornews.borland.com...
> > Because when you compile it as part of the project, it knows how to deal
> > with TDIJOYSTATE.  *Always* use the T when you define your own types,
> helps
> > remind you what it is.  If you see a T in front of a var in a stdcall,
you
> > can count on problems, since the marshalling will have to know how to
deal
> > with this type.

> > COM is a Microsoft animal and does not know about Delphi types.  You'll
> need
> > to use OleVariant or one of the standard COM types in order for this to
> work
> > indepentenly.

> > HTH,

> > Brandon Smith

> > Wendell W. Pinegar <Wend...@thePinegars.com> wrote in message
> > news:8fkmqk$qbq2@bornews.borland.com...
> > > I've designed a Compoent wrapper called TJoystick that is a wrapper
for
> > the
> > > DirectX 7.0 VB COM DirectInput objects.  The component compiles and
> works
> > > just fine when I simply include it as a part of my project, but when I
> > take
> > > the component and add it to a package (so I can then make it available
> on
> > > the component pallet) it always fails to compile and complains with
the
> > > error:

> > >    Types of actual and formal var parameters must be identical

> > > The line that it fails on is referencing the DeviceStateJoystick
> function
> > of
> > > a DirectInputDevice object.  The function is defined as:

> > >     function  GetDeviceStateJoystick(var state: DIJOYSTATE): HResult;
> > > stdcall;

> > > When I call the function I pass it a variable that was defined as a
> > > DIJOYSTATE, which is defined as the following in the type-library .pas
> > file:

> > >   DIJOYSTATE = packed record
> > >     x: Integer;
> > >     y: Integer;
> > >     z: Integer;
> > >     rx: Integer;
> > >     ry: Integer;
> > >     rz: Integer;
> > >     slider: array[0..1] of Integer;
> > >     POV: array[0..3] of Integer;
> > >     buttons: array[0..31] of Byte;
> > >   end;

> > > What I don't understand is why my component will compile correctly
when
> > > included in a project and generates this error when compiled as part
of
> a
> > > package.

> > > Anyone know what could be wrong?

> > > Sincerely,

> > > Wendell W. Pinegar

Re:D5: Component wrapper for COM Object doesn't compile in a package


Is it possible that you have two separate (same) definitions of DIJOYSTATE
somehow or your units are somehow referencing 2 xxx_TLB files on your
machine?

--
Binh Ly
http://www.techvanguards.com

Wendell W. Pinegar <Wend...@thePinegars.com> wrote in message
news:8fkmqk$qbq2@bornews.borland.com...

Quote
> I've designed a Compoent wrapper called TJoystick that is a wrapper for
the
> DirectX 7.0 VB COM DirectInput objects.  The component compiles and works
> just fine when I simply include it as a part of my project, but when I
take
> the component and add it to a package (so I can then make it available on
> the component pallet) it always fails to compile and complains with the
> error:

>    Types of actual and formal var parameters must be identical

> The line that it fails on is referencing the DeviceStateJoystick function
of
> a DirectInputDevice object.  The function is defined as:

>     function  GetDeviceStateJoystick(var state: DIJOYSTATE): HResult;
> stdcall;

> When I call the function I pass it a variable that was defined as a
> DIJOYSTATE, which is defined as the following in the type-library .pas
file:

>   DIJOYSTATE = packed record
>     x: Integer;
>     y: Integer;
>     z: Integer;
>     rx: Integer;
>     ry: Integer;
>     rz: Integer;
>     slider: array[0..1] of Integer;
>     POV: array[0..3] of Integer;
>     buttons: array[0..31] of Byte;
>   end;

> What I don't understand is why my component will compile correctly when
> included in a project and generates this error when compiled as part of a
> package.

> Anyone know what could be wrong?

> Sincerely,

> Wendell W. Pinegar

Re:D5: Component wrapper for COM Object doesn't compile in a package


Please do not post attachments to the Borland newsgroups as it goes against the
rules of use for these newsgroups (www.borland.com\newsgroups).  Only
borland.public.attachments can have attachments.  You post has been canceled.

Quote
"Wendell W. Pinegar" wrote:

>                    Name: Joystick.zip
>    Joystick.zip    Type: Zip Compressed Data (application/x-zip-compressed)
>                Encoding: x-uuencode

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted  corridors of Whitehall.
             (Fish)

Re:D5: Component wrapper for COM Object doesn't compile in a package


Okay,  I sent it directly to them instead.

"Jeff Overcash (TeamB)" <overc...@onramp.net> wrote in message
news:3922A996.7EB9C702@onramp.net...

Quote
> Please do not post attachments to the Borland newsgroups as it goes
against the
> rules of use for these newsgroups (www.borland.com\newsgroups).  Only
> borland.public.attachments can have attachments.  You post has been
canceled.

> "Wendell W. Pinegar" wrote:

> >                    Name: Joystick.zip
> >    Joystick.zip    Type: Zip Compressed Data

(application/x-zip-compressed)
Quote
> >                Encoding: x-uuencode

> --
> Jeff Overcash (TeamB)
>       (Please do not email me directly unless  asked. Thank You)
> And so I patrol in the valley of the shadow of the tricolor
> I must fear evil. For I am but mortal and mortals can only die.
> Asking questions, pleading answers from the nameless
> faceless watchers that stalk the carpeted  corridors of Whitehall.
>              (Fish)

Other Threads