Executing a COM function from a COM event in Visual Basic ?

Executing a COM function from a COM event in Visual Basic ?

Anonymous
Not applicable
490 Views
5 Replies
Message 1 of 6

Executing a COM function from a COM event in Visual Basic ?

Anonymous
Not applicable
Hello evrybody,

I have created an ARX file that i load in a visual basic project. This file
expose a COM object with events. Here is my problem :

In visual basic, in the main form i declare it like that :
____________________________________________________________

Dim WithEvents MyObj as MyArx.Application

' One of the event of MyObj :

Private Sub MyObj_OneEvent(Value1 as double, Value2 as double)
Dim NewValue

NewValue = SomeFunctionInVB (Value1, Value2)

MyObj.Function1(NewValue)

End Sub

' I'm making calculation in VB and sending back the result in C++.
____________________________________________________________

' Then, some calculation are done in C++ and Function1 will Fire a second
event :

Private Sub MyObj_OtherEvent (Value3 as double)

AnOtherFunctionInVB (Value3)

End Sub

_____________________________________________________________

My question is :

- Is it possible to execute a function from an event of the same COM class
(class ATL_NO_VTABLE CApplication :...) ?

It doesn't seem to work. I loose everything in AutoCAD, and also in Visual
Basic ... no answer ... When i try to execute the program in debug mode wiht
breakpoints in VC++, nothing happened ...

I use Visual Baisc 6, Visual C++ 6 and AutoCAD 2000 ... Without the Function
in the event, everything work very well.


What do you suggest ? Thank's.


Driss.
0 Likes
491 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
If this is the way your event is meant to be used, have you considered
passing the event arguments BYREF? Then you can just modify it and not have
to do anything to pass the new value back to your object.

--
Good judgment comes from experience.
Experience comes from bad judgment.

http://www.acadx.com


"Driss" wrote in message
news:[email protected]...
> Hello evrybody,
0 Likes
Message 3 of 6

Anonymous
Not applicable
Event handler arguments can be passed by reference.
Instead of passing the values themselves, you pass
pointers to them, and the client can modify them
directly.

If you're using ATL, there are some manual changes
needed to the wizard-generated Fire_Xxxxx() functions
(it generates incorrect code when the event parameters
are [out] or [in,out]).

Email me and I'll send you something that shows how
to modify the wizard code.
0 Likes
Message 4 of 6

Anonymous
Not applicable
Thank's Frank and Tony for your lights. Sure Tony, i'm interesting to have a look on any sample showing how to pass variable ByRef in event function (Fire_XXX)... i'm going to email you right now ...

Driss
0 Likes
Message 5 of 6

Anonymous
Not applicable
Tony,

Sorry about that ... but can you send me first a message or put your mail address on a next message because i'm writting these message from a web navigator (I.E. and Not Outlook or netscape) and your address is not writing in the messages, (or i can't find it).

My address is :

[email protected]

Thank's
Driss
0 Likes
Message 6 of 6

Anonymous
Not applicable
[email protected]

"NDriss" wrote in message news:[email protected]...
> Tony,
> Sorry about that ... but can you send me first a message or put your mail address on a next message because i'm writting these
message from a web navigator (I.E. and Not Outlook or netscape) and your address is not writing in the messages, (or i can't find
it).
>
> My address is :
>
> [email protected]
>
> Thank's
> Driss
>
>
0 Likes