PRB: Paint Problems with Drag and Drop of TreeView Items (248250)



The information in this article applies to:

  • Microsoft Windows 98, when used with:
    • the operating system: Microsoft Windows 95
    • the operating system: Microsoft Windows 98
  • Microsoft Windows NT Server 4.0
  • Microsoft Windows NT Workstation 4.0

This article was previously published under Q248250

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.

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.

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.

STATUS

This behavior is by design.

MORE INFORMATION

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!
   }
}
				

REFERENCES

For additional information, 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


Modification Type:MinorLast Reviewed:12/20/2004
Keywords:kbprb kbTreeView KB248250