How to handle VB AddressOf in VC? 
Author Message
 How to handle VB AddressOf in VC?

Hi,

I understand we can use AddressOf in VB5 or greater to send Callback
function. I just work like to know how to write a VC function to handle the
VB AddressOf pointer. Could anyone help?

For example:

VB6

Call VCCallBack(AddressOf MyFunction)

...

Public Function MyFunction
...
End Function

VC6

How to write the code to receive the procedure pointer to MyFunction and
call it from VC?

Any idea? TIA.

- Eric



Mon, 23 May 2005 23:27:26 GMT  
 How to handle VB AddressOf in VC?


Quote:
> I understand we can use AddressOf in VB5 or greater to send Callback
> function. I just work like to know how to write a VC function to handle
the
> VB AddressOf pointer. Could anyone help?

> For example:

> VB6
> Call VCCallBack(AddressOf MyFunction)
> ...
> Public Function MyFunction
> ...
> End Function

> VC6
> How to write the code to receive the procedure pointer to MyFunction and
> call it from VC?

> Any idea? TIA.

There are at least two ways you can do this.

This first way may also be compatible with C:

void FunctionX(int(*A)(int A, int B))
{
 // Use the function
 int X = (*A)(12,1);

Quote:
}

int MyCallbackFunction(int A, int B);

// To actually send the function
FunctionX(MyCallbackFunction);

The second way uses the OOP aspect of C++

class CallbackBase_FunctionX
{
public:
 virtual int Call(int A, int B) = 0; // Make this class "purely abstract"

Quote:
};

class MyCallbackFunction: public CallbackBase_FunctionX
{
public:
 virtual int Call(int A, int B)
 {
  // Code
 };

Quote:
};

I haven't tried compiling the code so this may be subject to a little syntax
correction, but it should demonstrate the idea well enough.

Also, this should work on any compiler.

Hope this helped
CJ



Mon, 30 May 2005 15:07:42 GMT  
 How to handle VB AddressOf in VC?
Also,

you probably should have sent your question to a more relevant group, like
comp.lang.c++ (maybe), or microsoft.public.vc.language, instead of a group
about debugging.

Sorry to the regular posters here if I was not suppost to respond to an
off-topic post. I didn't realize that I was in a topic-specific group. (Is
there a FAQ I should read?)

CJ



Mon, 30 May 2005 15:14:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to handle VB AddressOf in VC code?

2. Prototyping function to accept VB AddressOf operator

3. Prototyping VC++ DLL functions to accept VB's AddressOf function pointer

4. creating a sink in VC to handle events fired by VB Com Object

5. VB and VC or VB and VB

6. Using VB collections in a VB DLL in VC

7. Challenge/Help VB.NET VC++.NET VC++6.0

8. AddressOf in c++?

9. C# events handling vs VB

10. Passing a Com port handle from VB to a C DLL back and forth

11. VB API call to a C dll -- problem with handles

12. VB image list handle isn't fully accessible in VC++ ActiveX thru COM call

 

 
Powered by phpBB® Forum Software