Link to home
Start Free TrialLog in
Avatar of gorgar
gorgar

asked on

OCX control & push button


Hi,

I’ve created an OCX control with no need to click on it. Now, I want to trigger methods from that
control via clicking on an ordinary push button (I included OCX in my project so all classes and
their methods are available in my project). But, instead of my own code in imported OCX method
i got the following line:

       InvokeHelper(0x1, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

What I need is the way to trigger methods from an OCX without having to click on the control but
with clicking an ordinary push button.

Regards,
Gorg

ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gorgar
gorgar

ASKER


I am calling the member function of the wrapper class.
Still the same error :(

gorg

What error? Compiling error? Linking error? Run time error? Tell me the details please.
Avatar of gorgar

ASKER


well, it's not actually an error, it's not what i want it to be!

Let me be more specific: my test OCX (it's supposed to be something more than 'test', but later) contains only one method
void Hello (void) which i inserted via class wizard -> automation tab -> add method and which's supposed to display constant string. Nothing much. I compile and link OCX with no error. Then i insert OCX in my project and get HelloOCX class.
Hello method is there, but when i call it (by clicking not the control but the simple push button) instead of my hello message i get assertion failed and my original line in Hello method (just an AfxMessageBox) is replaced with line:

InvokeHelper(0x1, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

which cause assertion.


I cannot go on without having this fixed :(((

P.S. Thanx for your patience :))


regards,
gorg






The InvokeHelper line is correct. It is not possible to see the source code of an OCX.

How do you create the OCX in your window? If you place the OCX in a dialog box, it is created automatically when the dialog box is created. If you want to place the OCX in your window, you need to create it first. For example, the generated wrapper class is CTest. Look at the header file, it has a member function Create. Define a member variable CTest m_test for your window class. In your window class OnCreate message handler, call m_test.Create(_T("test"), WS_VISIBLE | WS_CHILD, rect, this, 0) to create the OCX. Then, when the button is clicked, call m_test.Hello.
Avatar of gorgar

ASKER


   Neither one version works! :((

Is it ok to send you small piece of code for check out? I mean
considering your free time and will...

regards,
gorg


chensu@hotmail.com