Microsoft KB Archive/139648

= PRB: OLE Drop Target Does Not Permit Drop =

Article ID: 139648

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 1.5 Professional Edition

 Microsoft Visual C++ 1.51

 Microsoft Visual C++ 1.52 Professional Edition

 Microsoft Visual C++ 2.0 Professional Edition</li></ul>

 Microsoft Visual C++ 2.1</li></ul>

 Microsoft Visual C++ 2.2</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q139648

<div class="symptoms_section">

SYMPTOMS
When you drag an OLE object over a given drop target window, the cursor feedback indicates that a drop is not allowed. However, the same object can be dropped on other drop targets successfully, and other objects can be dropped on the given drop target.

<div class="cause_section">

CAUSE
The object descriptor for the object indicates the size of the object is (0,0), and the drop target window's OnDragOver method is using the object rectangle to determine whether the object is within the client area of the window.

<div class="resolution_section">

RESOLUTION
If the computed position rectangle for a data object is empty, inflate the rectangle to size (1,1) before testing whether the rectangle is within the client area of the drop target window.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

MORE INFORMATION
Applications that register a window as an OLE drop target should probably check the position of a data object that is dragged over the window before permitting a drop to occur. For example, the MFC sample program Oclient performs the following check in its OnDragOver method: DROPEFFECT CMainView::OnDragOver(COleDataObject*,     DWORD grfKeyState, CPoint point) {     // adjust target rect by original cursor offset point -= m_dragOffset;

// check for point outside logical area (in hatched region) // GetTotalSize returns the size passed to SetScrollSizes CRect rectScroll(CPoint(0, 0), GetTotalSize);

CRect rectItem(point,m_dragSize); rectItem.OffsetRect(GetDeviceScrollPosition);

DROPEFFECT de = DROPEFFECT_NONE; CRect rectTemp; if (rectTemp.IntersectRect(rectScroll, rectItem)) {        //... figure out the drop effect }

//...update drop effect

return de; } However, for some objects, such as Microsoft Word version 6.0 Documents, the m_dragSize reported by the data object is (0,0). In this case, the call to IntersectRect returns FALSE, and the drop effect returned is DROPEFFECT_NONE.

When the object position rectangle is inflated to size (1,1), IntersectRect returns TRUE and the correct drop effect is returned. In the previous example, you would inflate the rectangle by adding the following lines after the rectItem is declared: if (rectItem.IsRectEmpty) {     // Some applications might have a null size in the object descriptor rectItem.InflateRect(1,1); }

Additional query words: 0Client drag/drop Word

Keywords: kbdragdrop kbprb KB139648

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.