|
In the original posters example, that is happening. The strvector is constructed in the exe. When the setvector method is called, a string that's been constructed in the DLL is added to the vector. Later, when the strvector is destructed in the executable, it'll call the string destructor, also in the executable. This will try to release memory from the DLLs heap, which it doesn't have access to unless you've used the DLL CRT.
|
|
|
|
|
Don't ask what was in my pipe.
|
|
|
|
|
hi all,
As i develop windows application in MFC and i am new to ATL/COM ,
for that which link or book are better to learn ATL/COM developement
send reply
|
|
|
|
|
|
I made a COM object in a DLL (VS 6.0, ATL wizard). And trying to fire event and handle it in browser (IE 6.0), but browser doesn't react.
What haven't I noticed?
========================================================
html page:
========================================================
<html><head>
<object name="loApp"
classid="clsid:B92CBD2B-E660-4164-8810-2F382237EFC9"
codebase="SimpleAtlCom.dll"
style="display:none"></object>
<script language="JScript">
function loApp::TotalMarks(TotalMarks){
alert(TotalMarks);
}
function mess(){
loApp.mess();
}
</script></head><body><form name="testForm">
<input type="button" value="mess()" onclick="mess()">
</form></body></html>
========================================================
Generated ConnectionPoint
========================================================
template <class T>
class CProxy_ISimpleObjEvents : public IConnectionPointImpl<T, &DIID__ISimpleObjEvents, CComDynamicUnkArray>
{
//Warning this class may be recreated by the wizard.
public:
VOID Fire_TotalMarks(SHORT TotalMarks)
{
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
MessageBox(NULL,(nConnections==0)?"==0":"!=0", NULL, MB_OK);
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
pvars[0] = TotalMarks;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
}
delete[] pvars;
}
};
|
|
|
|
|
Ilya R wrote: function mess(){
loApp.mess();
}
I think that is the problem. It seems that you do not have a function in the ActiveX that is called "mess ". Calling the right function in the ActiveX should do it.
this is this.
|
|
|
|
|
1)mess() is called:
// SimpleObj.cpp : Implementation of CSimpleObj
STDMETHODIMP CSimpleObj::mess()
{
MessageBox(NULL,"CSimpleObj::mess()", NULL, MB_OK);
Fire_TotalMarks(5);
return S_OK;
}
2)m_vec.GetSize()==0!!!!!
VOID Fire_TotalMarks(SHORT TotalMarks)
{
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
MessageBox(NULL,(nConnections==0)?"==0":"!=0", NULL, MB_OK);
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
pvars[0] = TotalMarks;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
}
}
delete[] pvars;
}
|
|
|
|
|
I think you are using a simple object in your ActiveX. Right now I don't know any way to solve the problem with the simple object (nConnections = 0), but if you can implement a Full Control , that should solve the problem immediately.
I will look into some way to receive events using the simple atl object in the webbrowser.
this is this.
|
|
|
|
|
You are comletely right!!! Full Control does work!!
But, of course, it's not so cute to supply GUI interface in a object while it's used only for calculation.
I also try to migrate my code to C++Builder6.0 (it has similiar wizard and create ATL source) and the (nConnections = 0) problem appeared.
I tried to use the same version of Delphi wizard (it generate Delphi code but using the same libs as Builder, i suppose) and Delphi works OK.
I found smth but can't still explain:
http://discuss.microsoft.com/SCRIPTS/WA-MSD.EXE?A2=ind9803c&L=atl&T=0&P=647
if you have ideas, please, share
Thanks a lot
|
|
|
|
|
/*add this*/#include <atlctl.h>
class ATL_NO_VTABLE CSun :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CSun, &CLSID_Sun>,
public IConnectionPointContainerImpl<CSun>,
public IDispatchImpl<ISun, &IID_ISun, &LIBID_SKYLib>,
public CProxy_ISunEvents< CSun >,
/*add this*/public IProvideClassInfo2Impl<&CLSID_Sun, &DIID__ISunEvents, &LIBID_SKYLib>,
/*add this*/public IPropertyNotifySinkCP<CSun>
{
public:
CSun()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_SUN)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CSun)
COM_INTERFACE_ENTRY(ISun)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
/*add this*/COM_INTERFACE_ENTRY(IProvideClassInfo)
/*add this*/COM_INTERFACE_ENTRY(IProvideClassInfo2)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CSun)
/*add this*/CONNECTION_POINT_ENTRY(DIID__ISunEvents)
CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
END_CONNECTION_POINT_MAP()
// ISun
public:
STDMETHOD(rise)();
};
|
|
|
|
|
Where should i look for information regarding collections using ATL.
Actually i want to implement a heirarichal object, similar to ADO.
Where each command object has recordset collection and each recordset has field collection.
Thanx in Advance
Z.A
|
|
|
|
|
|
If you want collections look at STL.
Steve
|
|
|
|
|
|
|
Thanks very much, i will try and discuss it with you later
|
|
|
|
|
Hi Gurus,
I have an ActiveX control that has an Edit control inside. I have embeded this control in IE. the problem is when i try to delete some text in Edit control using backspace key the browser takes me to the previous page instead of Erasing the text in Edit control. Does any one know how to deal with this situation
please its urgent
thanks
Muhammad Azam
|
|
|
|
|
Try handling the keystroke in the IOleInPlaceActiveObject::TranslateAccelerator method of your control. To test if this is the problem make an implementation that just returns S_OK and see if this stops IE from processing the keystroke when your control is active (it will...). I'm not sure how you've implemented your control (ATL, MFC, straight Win32, etc) so I can't be more specific.
Steve
|
|
|
|
|
thanks steve i will evaluate the posibility that u suggested
Azam
|
|
|
|
|
Hi All,
Can anyone tell me if a vector automatically sorts all its string entries in alphabetical order?
Thanks and Regards,
Anil
|
|
|
|
|
No it doesn't. You can sort it manually like this:
sort(vec.begin(), vec.end());
Or you could use a set or multiset .
Steve
|
|
|
|
|
Anil_vvs wrote: Can anyone tell me if a vector automatically sorts all its string entries in alphabetical order?
Try std::set instead of std::vector
|
|
|
|
|
std::set holds unique values. use std::multiset to emulate a sorted vector more closely..
Regards
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Do I need to create a window for an ActiveX component to display directshow video? If yes, what is the simplest way?
I have a directshow player, that I want to turn into an activex component.
The directshow player needs a windows handle of type HWND to display its image in that window.
I'm using ATL to create the ActiveX component. Currently I try to figure out, how to output my image on the surface of the activeX component.
- create a window or not?
- which handle to use?
// hand over the window handle
myVideo.setHwnd(hwnd);
// int the player
myVideo.initGraph();
// play
myVideo.playGraph();
|
|
|
|
|
Hi all,
I know STL enough to understand containers and iterators but going from Predicates to Unary/Binary and vice versa is a bit unclear to me.
I have
<br />
class CMyClass<br />
{<br />
public:<br />
inline CString GetID() const {return m_csID;}<br />
protected:<br />
CString m_csID;<br />
};<br />
Now suppose I want an array of CMyClass* and detect whether an object of a specified ID already exist. How can I use find_if ?
<br />
vector<CMyClass*> myarray;<br />
LPCTSTR lpszNewID = _T("NEWID");<br />
if (find_if(myarray.begin(), myarray.end(), IsID(lpszNewID)???) != myarray.end())<br />
Any idea how to implement and properly use the "IsID(LPCTSTR lpszID)" part?
Thank you
|
|
|
|