Communication between OCX controls
Ravi Vaddepally -- ravirao@bellcore.com Tuesday, January 23, 1996 In my application I use 2 OCX controls, created by using CWnd::CreateControl method. my application requires these 2 OCX controls to talk to each other, like one control invoking methods on the other and vice versa. One idea that came up in my mind is to get an interface pointer to the OCX control that needs to be talked to and invoke that interface methods. Well, the problem is - I don't have a clue as to how to do it. Any suggestions ??? - Ravi ravirao@mailee.bellcore.com p.s: I am using VC++ 4.0 on NT.
paf Pete Ferreira Wednesday, January 24, 1996 [Mini-digest: 2 responses] > > In my application I use 2 OCX controls, created by using > CWnd::CreateControl method. > my application requires these 2 OCX controls to talk to each other, like > one control invoking methods on the other and vice versa. > One idea that came up in my mind is to get an interface pointer to > the OCX control that needs to be talked to and invoke that interface > methods. Well, the problem is - I don't have a clue as to how to do it. > > Any suggestions ??? > an OCX can ask its container to list all the objects it contains and thus get an interface pointer to the other OCX. Pete paf@netcom.com http://www.webcom.com/paf/pete.html -----From: nitink@sherpa.com Hi, Ravi: I assume that you have imported the controls into your project via Component Gallery, declared variables for them, and then used CWnd::CreateControl to actually create them. If that's the case, then your application already has variables for each control, and should be able to supply a pointer to each control to the other one. If, instead, you are looking for an interface pointer to each one [say because they don't know about each other's classes and want to communicate via OLE Automation or some other interface], then you could use the "CWnd::GetControlUnknown()" method on each of them to get their interface pointers, and then pass those pointers to each other as described above. Hope this helps. Nitin Karandikar nitink@sherpa.com
Dale Wilson -- dale@dra.com Tuesday, January 30, 1996 [Mini-digest: 2 responses] >> In my application I use 2 OCX controls, created by using >> CWnd::CreateControl method. >> my application requires these 2 OCX controls to talk to each other, like >> one control invoking methods on the other and vice versa. >> One idea that came up in my mind is to get an interface pointer to >> the OCX control that needs to be talked to and invoke that interface >> methods. Well, the problem is - I don't have a clue as to how to do it. >> >> Any suggestions ??? >> > >an OCX can ask its container to list all the objects it contains >and thus get an interface pointer to the other OCX. > >Pete >paf@netcom.com http://www.webcom.com/paf/pete.html Have you tried this, Pete? I get a NOT IMPLEMENTED status when I attempt to enumerate my peer OCX's in VC/MFC generated containers (it's been a while since I gave up on this so I don't remember the exact technique I tried to find them.) Dale Wilson dale@dra.com -----From: ravirao@bellcore.com (Ravi Vaddepally) I posted a message on communication between OCX controls before and got a couple of responses but neither of those exactly addressed my problem. My problem in brief is as follows: My application creates a window, calls a dll and passes the handle to the window to it. Dll subclasses the window (passed to it) and displays this on the application frame. This window has also the responsibility to create an OCX using CWnd::CreateControl and display it in its client area. The application creates separate instance of the above DLL for each OCX control. Now my question is how these controls can be made to communicate with each other ?? one solution may be is to get a dispatch interface (is this possible ?) and invoke the methods but there is one potential ambiguity - what if there are a number of instances of an OCX control ? Any help is greatly appreciated. -Ravi
paf Pete Ferreira Wednesday, January 31, 1996 > > >> In my application I use 2 OCX controls, created by using > >> CWnd::CreateControl method. > >> my application requires these 2 OCX controls to talk to each other, like > >> one control invoking methods on the other and vice versa. > >> One idea that came up in my mind is to get an interface pointer to > >> the OCX control that needs to be talked to and invoke that interface > >> methods. Well, the problem is - I don't have a clue as to how to do it. > >> > >> Any suggestions ??? > >> > > > >an OCX can ask its container to list all the objects it contains > >and thus get an interface pointer to the other OCX. > > > > Have you tried this, Pete? I get a NOT IMPLEMENTED status when I attempt to > enumerate my peer OCX's in VC/MFC generated containers (it's been a while > since I gave up on this so I don't remember the exact technique I tried to > find them.) > I haven't tried it with an MFC-based container. According to "OLE Controls and Control Containers Guidelines, ver. 1.1" all OLE containers must implement IOleContainer::EnumObjects, or they're not OLE containers. Pete paf@netcom.com
Sridhar Rao Chedalla -- C.Sridhar@blr.sni.de Wednesday, January 01, 1997 Hello , Environment : VC++ 4.2-flat, Win NT 4.0 I have developed two OCX controls. In the first control I exposed one method DisplayMessage() which takes no parameters and return void and I have built type library file. Then I have created second OCX control and created one class _DNAServer from the type lib generated by the first OCX control. Then in the OCX control I have taken this as a data member and in the OnLButtonDown of the second OCX control I wrote the following code. void CMyOCXCtrl::OnLButtonDown(UINT nFlags, CPoint point) { COleControl::OnLButtonDown(nFlags, point); COleException e; // "ANCONTROL.ANControlCtrl.1" is the progid. of first control LPCTSTR str1 = _T("ANCONTROL.ANControlCtrl.1"); if (!driver.CreateDispatch(str1, &e)) AfxMessageBox("Unable to create dispatch"); ASSERT(driver.m_lpDispatch != NULL); driver.DisplayMessage(); // When executed we get Catastrophic error. } DisplayMessage() of the first control has no body but it simply returns(I just want to test DisplayMessage() method). When I run the two controls from MSVC OLE test container it is giving me error "Catastrophic Failure". I have debuggedd and found that I am getting the error only when I call the DisplayMessage() function. May I know what is the problem in this. Thanks in Advance. C.Sridhar
Sridhar Rao Chedalla -- C.Sridhar@blr.sni.de Wednesday, January 01, 1997 Hello , Environment : VC++ 4.2-flat, Win NT 4.0 I have developed two OCX controls. In the first control I exposed one method DisplayMessage() which takes no parameters and return void and I have built type library file. Then I have created second OCX control and created one class _DNAServer from the type lib generated by the first OCX control. Then in the OCX control I have taken this as a data member and in the OnLButtonDown of the second OCX control I wrote the following code. void CMyOCXCtrl::OnLButtonDown(UINT nFlags, CPoint point) { COleControl::OnLButtonDown(nFlags, point); COleException e; // "ANCONTROL.ANControlCtrl.1" is the progid. of first control LPCTSTR str1 = _T("ANCONTROL.ANControlCtrl.1"); if (!driver.CreateDispatch(str1, &e)) AfxMessageBox("Unable to create dispatch"); ASSERT(driver.m_lpDispatch != NULL); driver.DisplayMessage(); // When executed we get Catastrophic error. } DisplayMessage() of the first control has no body but it simply returns(I just want to test DisplayMessage() method). When I run the two controls from MSVC OLE test container it is giving me error "Catastrophic Failure". I have debuggedd and found that I am getting the error only when I call the DisplayMessage() function. May I know what is the problem in this. C.Sridhar
| Вернуться в корень Архива |