Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ListView and drag and drop

152 views
Skip to first unread message

Nicolas Mugnier

unread,
May 13, 2003, 6:34:07 AM5/13/03
to
Hi,

I would like to create a dialog window with two list views in report mode. I
would like to be able to drag objects selected from the first list view and
drop them in the second list view. How could I do this ?

Any help would be welcome!

Christian ASTOR

unread,
May 13, 2003, 7:22:25 AM5/13/03
to

Nicolas Mugnier a écrit:

> I would like to create a dialog window with two list views in report mode. I
> would like to be able to drag objects selected from the first list view and
> drop them in the second list view. How could I do this ?

On LVN_BEGINDRAG notification :
ImageList_Create()
ImageList_AddMasked()
ImageList_BeginDrag()
ImageList_DragEnter()
SetCapture()

On WM_MOUSEMOVE:
GetCursorPos()-WindowFromPoint() to get destination hWnd
ImageList_DragMove()
ListView_HitTest()


On WM_LBUTTONUP:
Loop on selected items (LVIS_SELECTED) and insert in destination
ListView (eventually ListView_DeleteItem() on origin ListView to move items)
ImageList_DragLeave()
ImageList_EndDrag()
ReleaseCapture()
ImageList_Destroy()

(use also a timer to scroll the destination ListView and display the
cursor ((GetKeyState( VK_CONTROL ) & 0x8000) for move or copy items)
)(ImageList_DragShowNolock(FALSE)-WM_VSCROLL-ImageList_DragShowNolock(
TRUE ))
(and see KB 214814 for similar example on Treeview)


mike

unread,
May 13, 2003, 12:22:27 PM5/13/03
to
In article <OYlYusTG...@TK2MSFTNGP12.phx.gbl>, nicolas...@cesa.fr says...

If you are familiar with C++ templates, you might want to
consider creating a generic dragger that takes functors for
"update drag" and "end drag". It is very handy for stuff like
this. I've used it for your problem, although I just flip up
a different cursor for allowed drops instead of a bitmap. Let
me know if you want to see it.

mike

Nicolas Mugnier

unread,
May 23, 2003, 10:47:56 AM5/23/03
to
I don't use C++. Sorry!

"mike" <winte...@operamail.com> a écrit dans le message de news:
MPG.192ad7aae...@msnews.microsoft.com...

0 new messages