Board index » delphi » Two cursors displayed during drag and drop operation

Two cursors displayed during drag and drop operation

I have a MDI application consisting of two TTreeView controls in two
windows
seperated by a splitter control.  It is required to drag items from one
TTreeView
to another.  The drag mode is set to dmManual for both the TreeViews.

The problem is that when an item is dragged from one TreeView  to
another, two cursors
are displayed.  One of them is crNoDrop and the other is either crNoDrop
or crDrag.

This problem does not occur if there is no ImageList associated with
TTreeView.

Any Ideas ?

Thanks,
DT

 

Re:Two cursors displayed during drag and drop operation


Hi,
I had a similar problem with Drag&Drop on a TreeView control. As it
turned out, the problem is caused by incorrect handling of cancellation
of a drag operation when a delayed initiation is used -
BeginDrag(False). *sigh* one of those annoying bugs...

The general idea of my solution is to implement delayed initiation by
yourself: inherit your own TreeView control from TCustomTreeView, save
the mouse coordinates in WMLButtonDown and calculate the distance
between the current and the saved positions in WMMouseMove. When the
distance reaches a pre-defined 'delta' initiate immediate dragging
operation. This way your dragging cursor will not be garbled any more.
This is just a basic idea, if you want to see a piece of code that
solves this problem, drop me a line.

-Vladimir

Quote
Dharmendra Thakkar wrote:

> I have a MDI application consisting of two TTreeView controls in two
> windows
> seperated by a splitter control.  It is required to drag items from one
> TTreeView
> to another.  The drag mode is set to dmManual for both the TreeViews.

> The problem is that when an item is dragged from one TreeView  to
> another, two cursors
> are displayed.  One of them is crNoDrop and the other is either crNoDrop
> or crDrag.

> This problem does not occur if there is no ImageList associated with
> TTreeView.

> Any Ideas ?

> Thanks,
> DT

Re:Two cursors displayed during drag and drop operation


Hello there,

it is a bug in the TTreeView and TListView in Delphi and C++Builder.
The problem occurs only when you hit and release the TreeItem or
ListItem before it is generating the DragCursor. (DragImageCursor).
In the source code of the component somebody makes a beginner
mistake. In BeginDrag(), the winapi function ShowCursor(true) is called.
It is returning the number of cursor. When you hit your item and
you do not move the cursor 5 pixel in each direction the system
is not calling ShowCursor(false) in the internal EndDrag().
Now you have two cursor. Good luck.

Example / workaround in my program written in C++.
//--------------------------------------------------------------------------
-
void __fastcall TListStruktForm::ListViewEndDrag(TObject *Sender, TObject
*Target,
        int X, int Y)
{
  int nlWrongCursor;

  nlWrongCursor = ShowCursor( true );
  while ( nlWrongCursor > 0 )
    nlWrongCursor = ShowCursor( false );

Quote
}

Harald.

Dharmendra Thakkar <dthak...@us.ibm.com> schrieb im Beitrag
<35755480.E1DF3...@us.ibm.com>...

Quote
> I have a MDI application consisting of two TTreeView controls in two
> windows
> seperated by a splitter control.  It is required to drag items from one
> TTreeView
> to another.  The drag mode is set to dmManual for both the TreeViews.

> The problem is that when an item is dragged from one TreeView  to
> another, two cursors
> are displayed.  One of them is crNoDrop and the other is either crNoDrop
> or crDrag.

> This problem does not occur if there is no ImageList associated with
> TTreeView.

> Any Ideas ?

> Thanks,
> DT

Other Threads