Microsoft KB Archive/248250

= PRB: Paint Problems with Drag and Drop of TreeView Items =

Article ID: 248250

Article Last Modified on 2/12/2007

-

APPLIES TO

 Microsoft Windows 98 Standard Edition, when used with:  Microsoft Windows 95

 Microsoft Windows 98 Standard Edition  Microsoft Windows NT Server 4.0 Standard Edition Microsoft Windows NT Workstation 4.0 Developer Edition

-

<div class="notice_section">

This article was previously published under Q248250

<div class="symptoms_section">

SYMPTOMS
When dragging a TreeView item, if the ToolTips for underlying items are displayed during the drag operation, paint problems may occur because the remnants of the old ToolTips may not be completely erased. These remnants are visible in the vertical scroll bar (if present) and over the underlying windows.

<div class="cause_section">

CAUSE
During a drag operation, the SetCapture function is used to direct mouse input to the window involved in the drag operation. This conflicts with the ToolTip control's operation, inhibiting the ToolTip's ability to erase itself.

<div class="resolution_section">

RESOLUTION
To prevent ToolTip artifacts during a drag-and-drop operation, you must de-activate the ToolTip control that is associated with the TreeView control during the drag operation, and then re-activate it after the drag operation is done or cancelled.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce Behavior
The TREESCRL sample reproduces the behavior after the following changes to the string data in the code. For additional information on the TREESCRL sample, click the article number below to view the article in the Microsoft Knowledge Base:

162159 SAMPLE:TREESCRL Scrolls in a Tree Control During Drag-and-Drop


 * 1) Insert items that are greater than the size of the window.
 * 2) Resize the window to show the horizontal scrollbar.
 * 3) Make sure that all or some of the items are displaying ToolTips while the mouse is moved over the items.
 * 4) Drag a TreeView item over the other items.
 * 5) The remnants of the old ToolTips show up on the vertical scrollbar (if any) and outside of the TreeView control.

The following changes, denoted by KK_ADD in the OnBeginDrag and OnButtonUp functions of the View.cpp file in the TREESCRL sample, resolve the problem: void CTreeScrollView::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult) {  NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;

m_pTreeCtrl->GetToolTips->Activate(FALSE); // KK_ADD: NO TOOLTIPS PLEASE.

CPoint ptAction;

// other lines

*pResult = 0; }

void CTreeScrollView::OnButtonUp // called from OnLButtonUp {  if (m_bDragging) {     // other lines

m_pTreeCtrl->GetToolTips->Activate(TRUE); // KK_ADD: ToolTips OK! } }

<div class="references_section">