[prev in list] [next in list] [prev in thread] [next in thread]
List: ms-atl
Subject: Re: Can connection point event pass a variant and so on?
From: Jiaxu Li <jli () SFAMIPEC ! COM>
Date: 2000-10-31 17:20:08
[Download RAW message or body]
I answered the first question myself.
The Wizard generates code as
void Fire_OnEvent(VARIANT newVal)
{
...
CComVariant *pVar[1];
pVar[0] = &newVal;
...
}
The operator = in CComVariant will use its InternalCopy(...). This causes
the error. I modified the Wizard code to pVar->Copy( &newVal ); then works.
Thanks for reading!
JLi
-----Original Message-----
From: Jiaxu Li [mailto:jli@SFAMIPEC.COM]
Sent: Thursday, October 26, 2000 4:59 PM
To: ATL@DISCUSS.MICROSOFT.COM
Subject: Re: Can connection point event pass a variant and so on?
Sorry for misprints !!
In 1, I meant "I CAN NOT compile ..." instead of "I can compile ...;
In 2, "class CMyClass" should be "struct ItemStruct".
Sorry about that!!
JL
-----Original Message-----
From: Jiaxu Li [mailto:jli@SFAMIPEC.COM]
Sent: Thursday, October 26, 2000 4:41 PM
To: ATL@DISCUSS.MICROSOFT.COM
Subject: Can connection point event pass a variant and so on?
I have two questions as follows.
1. I use ATL connection point to raise some events. One is called
Fire_OnData(). Ideally, I like to pass a variant (containing
multi-dimensional SafeArray) to clients, i.e., Fire_OnData ( VARIANT newVal
);. On client side, clients will implement OnData(.) and play with the
variant.
But, I can compile my ATL COM server code. The error is the variant is
truncated to boolean.
I take an alternative approach for test purpose (other parts).
a) Fire event without parameter, Fire_OnData();.
b) Write another method get_Data(VARIANT newVal) so that clients can get the
data after received the event.
This costs me an extra round trip.
Please let me know if I can pass variant through the event method. ( I have
no problem to pass long and BSTR. ) Thank you in advance!
2. I use STL queue to queue my user defined class CMyClass in the way
#typedef struct {
...
} ItemStruct;
#typedef queue<ItemStruct> MYQUEUE
MYQUEUE myQ;
My code likes
///////////////////////////////
{
ObjectLock(this);
while ( !myQ.empty() )
{
ItemStruct item;
item = myQ.front(); // <- the line at which the program
fails.
// do some things on item
myQ.pop();
}
}
///////////////////////////////
After 3.5 hours running and looping 290,000+ times, it fails at the line
"item = myQ.front();". Entering debug mode, I saw myQ.empty() returns 0 and
myQ.front() returns error. This gives me the impression that the queue
contains a garbage item. I'm sure it is not from client. Can anyone tell me
what's wrong? Thank you in advance again!
JLI
----------------------------------------------------------------
Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe. Save time, search
the archives at http://discuss.microsoft.com/archives/index.html
----------------------------------------------------------------
Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe. Save time, search
the archives at http://discuss.microsoft.com/archives/index.html
----------------------------------------------------------------
Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe. Save time, search
the archives at http://discuss.microsoft.com/archives/index.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic