Link to home
Start Free TrialLog in
Avatar of kamp007
kamp007

asked on

How to call method of an ActiveX control from inside VC++ project.

Hi all,

 I have developed an ActiveX control (using VB), which will plot some data for 5 seconds. Now i have written a method that can accept the the time in run time.

Then i inserted the ActiveX by right clicking on dialog box & include ActiveX control, it works fine then i did not see any wrapper classes. (but when i included this control by clicking project->include object-> this activex control, I could see wrapper class created for this but i did not know how to display this in the dialog box.

 And i have no idea of how to call the method there so that the graph is plotted for the new time interval that i pass from inside VC++.

 Thanks in advance

 Kalai
Avatar of jimbucci
jimbucci

You have to get the IDispatch pointer to the ActiveX control then call its method.

  ICtrlPtr pCtl;
  IUnknown* pIUnk = NULL;
  if SUCCEEDED(GetDlgControl(IDC_Control,
                             __uuidof(IUnknown),
                            (void**)&pIUnk))
  {
     pCtl = pIUnk;
     pCtl->MethodCall();
  }

IDC_Control is your resource ID for the ActiveX control.

I hope this helps.
Jim
Avatar of kamp007

ASKER

Even though i know C++, i am not a experienced VC++ programmer. So I am not sure about what u said. Can you please explain it clearly. And I am sorry i forgot to say that, i inserted the ActiveX by right clicking on dialog box & include ActiveX control, then i did not see any wrapper classes.
Thanks again
Kalai
ASKER CERTIFIED SOLUTION
Avatar of jimbucci
jimbucci

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 kamp007

ASKER

def that helps. But i read some MFC book and figured out myself about how to pass a pointer to a Control item. But thanks for your reply.
kalai