Click to See Complete Forum and Search --> : Why my CView derived class can't register a COleDropTarget?


Noodle
April 8th, 1999, 03:23 PM
I still can't register COleDropTarget, I had try it in my CView derived class, CFormView derived class and CListView derived class, register return a 0. I find the problem is :

BOOL COleDropTarget::Register(CWnd* pWnd)
{
ASSERT_VALID(this);
ASSERT(m_hWnd == NULL); // registering drop target twice?
ASSERT_VALID(pWnd);

LPUNKNOWN lpUnknown = (LPUNKNOWN)GetInterface(&IID_IUnknown);
ASSERT(lpUnknown != NULL);

// the object must be locked externally to keep LRPC connections alive
if (CoLockObjectExternal(lpUnknown, TRUE, FALSE) != S_OK)
>> return FALSE;
.
.
.
}
CoLockObjectExternal(lpUnknown, TRUE, FALSE) return a not S_OK, why? and how could I get it?
Thanks!!!

Noodle
April 8th, 1999, 03:47 PM
I write a class derived from CWnd, and create COleDropTarget for it, Register this COleDropTarget in OnCreate() function.
In most time, it's can't work, but some time(in debug mode) it can work.
Why?