Failure to Register DropTarget only on HP Vectra and Win 2000
-
I have a unique problem that is only showing up when I run Chris's grid control under windows 2000 on a HP Vectra. I can not reproduce in under any other condition. This involves the Drag Drop registration. On the HP the registration fails on the first call. Initially it appeared that the window handle was incorrect but this is not the case. The grid has a proper handle and the drop target is null. In tracing the code (on the HP) Chris's code BOOL CGridDropTarget::Register(CGridCtrl *pGridCtrl) { if (m_bRegistered) return FALSE; // Stop re-entry problems static BOOL bInProcedure = FALSE; if (bInProcedure) return FALSE; bInProcedure = TRUE; ASSERT(pGridCtrl->IsKindOf(RUNTIME_CLASS(CGridCtrl))); ASSERT(pGridCtrl); if (!pGridCtrl || !pGridCtrl->IsKindOf(RUNTIME_CLASS(CGridCtrl))) { bInProcedure = FALSE; return FALSE; } m_pGridCtrl = pGridCtrl; ASSERT (COleDropTarget::m_hWnd==NULL); // OK HERE m_bRegistered = COleDropTarget::Register(pGridCtrl); // THis call failes on the HP bInProcedure = FALSE; return m_bRegistered; } COleDropTraget Code: 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; // connect the HWND to the IDropTarget implementation if (RegisterDragDrop(pWnd->m_hWnd, (LPDROPTARGET)GetInterface(&IID_IDropTarget)) != S_OK) // Failure here but when should it not?? { CoLockObjectExternal(lpUnknown, FALSE, FALSE); return FALSE; } // connect internal data m_hWnd = pWnd->m_hWnd; ASSERT(pWnd->m_pDropTarget == NULL); pWnd->m_pDropTarget = this; return TRUE; } In RegisterDragDrop: The first argument is the handle to the window that excepts the drop. Now the trace gets "lost" in the os at this point. On the HP the next viewable code in the call stack following the assert is in a CWnd::Attach with the handle of the grid and it asserts since it is not null. It seems that this should have been the handle to the droptarget. So what is wrong with the HP's to link in this code or why does it not fail on all platforms??? On other platforms it step right though this section with no problems and all