SAFEARRAY in event 
Author Message
 SAFEARRAY in event

(Creating an ATL EXE server, VC6, SP5.)

I am trying to create an event (usable by VB) in which I pass a safearray of
bytes.  Here's the idl definition:

[id(1), helpstring("method TestEvent")] HRESULT TestEvent([in, out]
SAFEARRAY(unsigned char) *TestBuf);

I used ([in, out] SAFEARRAY(unsigned char) *TestBuf) since this is what VB
itself generates in the idl when I create an activeX dll with an event in the
class as follows:

Public Event TestEvent(TestBuf() As Byte)

(This I learned from looking at the IDL of the activeX dll with OLE View.)

When I try to implement the connection point however, I get the following
compile warning:

warning C4800: 'struct tagSAFEARRAY ** ' : forcing value to bool 'true' or
'false' (performance warning)

This is similar to what I get when I try using ([in] VARIANT TestBuf) in the
event.  This bug is documented however and all I have to do is remove the & from
the line

pvars[0] = &TestBuf;

from the ATL generated code to fix the problem.  But in the SAFEARRAY case, I
can't get rid of the warning, and even though it compiles, VB never sees the
event when I fire it.

Can someone please explain what's going on, or point me to a reference where I
can try to learn it myself?  Is there a similar bug for SAFEARRAYs?  I know I
can work around it by using a VARIANT, but (1) I'd like to be more specific
about the data types in the IDL than just VARIANT, (2) VARIANT is going away in
VB.NET (I think I read that somewhere), and I don't know what problems that will
cause, and (3) I just want to understand what's happening.  I want to be able to
use this interface with some VB clients, but even more so, I'd like to make sure
I'm writing 'proper' interfaces.

Thanks in advance.

--

*************************************************
Patrick Noffke
QTI
Sussex, WI
*************************************************



Mon, 06 Oct 2003 23:55:42 GMT  
 SAFEARRAY in event
See your answer in microsoft.public.vc.activex.templatelib

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> (Creating an ATL EXE server, VC6, SP5.)

> I am trying to create an event (usable by VB) in which I pass a safearray
of
> bytes.  Here's the idl definition:

> [id(1), helpstring("method TestEvent")] HRESULT TestEvent([in, out]
> SAFEARRAY(unsigned char) *TestBuf);

> I used ([in, out] SAFEARRAY(unsigned char) *TestBuf) since this is what VB
> itself generates in the idl when I create an activeX dll with an event in
the
> class as follows:

> Public Event TestEvent(TestBuf() As Byte)

> (This I learned from looking at the IDL of the activeX dll with OLE View.)

> When I try to implement the connection point however, I get the following
> compile warning:

> warning C4800: 'struct tagSAFEARRAY ** ' : forcing value to bool 'true' or
> 'false' (performance warning)

> This is similar to what I get when I try using ([in] VARIANT TestBuf) in
the
> event.  This bug is documented however and all I have to do is remove the
& from
> the line

> pvars[0] = &TestBuf;

> from the ATL generated code to fix the problem.  But in the SAFEARRAY
case, I
> can't get rid of the warning, and even though it compiles, VB never sees
the
> event when I fire it.

> Can someone please explain what's going on, or point me to a reference
where I
> can try to learn it myself?  Is there a similar bug for SAFEARRAYs?  I
know I
> can work around it by using a VARIANT, but (1) I'd like to be more
specific
> about the data types in the IDL than just VARIANT, (2) VARIANT is going
away in
> VB.NET (I think I read that somewhere), and I don't know what problems
that will
> cause, and (3) I just want to understand what's happening.  I want to be
able to
> use this interface with some VB clients, but even more so, I'd like to
make sure
> I'm writing 'proper' interfaces.

> Thanks in advance.

> --

> *************************************************
> Patrick Noffke
> QTI
> Sussex, WI
> *************************************************



Tue, 07 Oct 2003 03:35:19 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. SAFEARRAY as event argument

2. Problem firing an event from ATL to VB which passes a SAFEARRAY

3. Safearray as Variant parameter to an Event

4. Passing a Safearray in an event

5. Method vs Event and Safearray's

6. Copy 1D safeArray to 2D safearray

7. How to create safearray or safearray?

8. Accessing Safearray of Safearrays in C++

9. Unified Event Model - VC7.0 C++ Unmanaged Events

10. Why Mouse Mouse event with every Click event

11. mouse down event interfearnig with double click event

12. event help needed (events with string name parameters)

 

 
Powered by phpBB® Forum Software