1

Topic: How to organize registration Callback of ActiveX (ATL) a component

- I have DLL-ku which is written on Si ( to driver Bluetooth) and which has event handling from the driver by means of setting Callback.

- I have ActiveX a component-cover to this DLL-ke, created in VS2008 by means of technology ATL.

All is remarkable - methods in DLL work, properties change.

One BUT.

There is a pair of events, which  DLL.

To them it is possible to cling by means of standard Si-shnyh of callback-functions (in this case - even without arguments, it is pure notification messages).


Wrote static - without arguments which gave in DLL-ku as Callback-a in the designer of a component.

.

Faced a problem: event in most Ah-component is generated by a call of its function-internal of public method FireMyNotyfyEvent ().

all ATL-code also did not find a variable through which it is possible to reach a class method from the outside.


Tried to create a static variable-index on a copy  a class and to initialize it in designer AX of a component. And then to pull through it of medical odes of generation of event in a component.

The regional ohm - a method is caused, but  on access obtaining to the local data.

If the same method FireMyNotyfyEvent () to cause from other method of a class of a component, all transits normally - event .

Means - a problem in the correct method call of a class of component FireMyNotyfyEvent () from exterior static callback-function.


Both static function and its prototype in DLL have identical Si-shnyj a format of the agreement on a call of functions. Here the dirty trick with a stack is not present.

But on a class I probably receive the pointer incorrect, or inadmissible for access to a class method.


How it is correct to pull a class method AH from exterior static function?

2

Re: How to organize registration Callback of ActiveX (ATL) a component

Hello, anpis, you wrote:


<skip>

A> If the same method FireMyNotyfyEvent () to cause from other method of a class of a component, all transits normally  event .
A> Means  a problem in the correct method call of a class of component FireMyNotyfyEvent () from exterior static callback-function.

Most likely FireMyNotyfyEvent it is caused not in that flow and is not present . If adjustments ActiveX by default it, most likely, STA and COM-eventy it is necessary or to throw in the same flow in which the COM object has been created or to organize .

3

Re: How to organize registration Callback of ActiveX (ATL) a component

Hello, the Anonymous author, you wrote:

Hello, anpis, you wrote:

Most likely FireMyNotyfyEvent it is caused not in that flow and is not present . If adjustments ActiveX by default it, most likely, STA and COM-eventy it is necessary or to throw in the same flow in which the COM object has been created or to organize .


Thanks for idea.

What adjustments and where it is necessary to change?

At me the simple one-continuous task with exclusive usage of this component in all system.

The component created by means of Wizard with adjustments on-default.

4

Re: How to organize registration Callback of ActiveX (ATL) a component

Hello, anpis, you wrote:

A> Hello, the Anonymous author, you wrote:

> Hello, anpis, you wrote:

> Most likely FireMyNotyfyEvent it is caused not in that flow and is not present . If adjustments ActiveX by default it, most likely, STA and COM-eventy it is necessary or to throw in the same flow in which the COM object has been created or to organize .

A> Thanks for idea.
A> What adjustments and where it is necessary to change?
A> At me the simple one-continuous task with exclusive usage of this component in all system.
A> the Component created by means of Wizard with adjustments on-default.


Can be to raise the question differently: how to jostle from AH component the Callback in DLL?


Itself DLL it is written by me and I am free to make any stub function to it. Including for example - to accept the pointer on callback from Ah-component.

But it from  functions in DLL will be caused.

How she is correct for declaring to observe the agreement for function invocation?

5

Re: How to organize registration Callback of ActiveX (ATL) a component

Hello, anpis, you wrote:

A> Hello, anpis, you wrote:

A>> Hello, the Anonymous author, you wrote:

>> Hello, anpis, you wrote:

>> Most likely FireMyNotyfyEvent it is caused not in that flow and is not present . If adjustments ActiveX by default it, most likely, STA and COM-eventy it is necessary or to throw in the same flow in which the COM object has been created or to organize .

A>> Thanks for idea.
A>> What adjustments and where it is necessary to change?
A>> At me the simple one-continuous task with exclusive usage of this component in all system.
A>> the Component created by means of Wizard with adjustments on-default.

A> Can be to raise the question differently: how to jostle from AH component the Callback in DLL?

A> Itself DLL it is written by me and I am free to make any stub function to it. Including for example  to accept the pointer on callback from Ah-component.
A> But it from  functions in DLL will be caused.
A> As she is correct for declaring to observe the agreement for function invocation?


SOLVED THE PROBLEM!!

Really - it is constructed AH in other flow and initialization of the global pointer directly from the designer does not achieve the object
sad .

global function through which I transfer the pointer from the designer for initialization of a global pointer to a class.