Справочник функций

Ваш аккаунт

Войти через: 
Забыли пароль?
Регистрация
Информацию о новых материалах можно получать и без регистрации:

Почтовая рассылка

Подписчиков: -1
Последний выпуск: 19.06.2015

Как сделать Drag and Drop

292
10 апреля 2006 года
Matush
726 / / 14.01.2004
К примеру у меня в окне есть CTreeCtrl и CListctrl.
Как сделать drag and drop из списка в дерево?
406
10 апреля 2006 года
vitaly2003s
481 / / 27.07.2004
Цитата:
Originally posted by Matush
К примеру у меня в окне есть CTreeCtrl и CListctrl.
Как сделать drag and drop из списка в дерево?


Посмотри в сторону TVN_BEGINDRAG,LVN_BEGINDRAG.

Вот немного из MSDN:

Drag-and-Drop Operations
A tree-view control notifies the parent window when the user starts to drag an item. The parent window receives a TVN_BEGINDRAG notification message when the user begins dragging an item with the left mouse button and a TVN_BEGINRDRAG notification message when the user begins dragging with the right button. You can prevent a tree-view control from sending these notifications by giving the tree-view control the TVS_DISABLEDRAGDROP style.

You obtain an image to display during a drag operation by using the TVM_CREATEDRAGIMAGE message. The tree-view control creates a dragging bitmap based on the label of the item being dragged. Then the tree-view control creates an image list, adds the bitmap to it, and returns the handle to the image list.

You must provide the code that actually drags the item. This typically involves using the dragging capabilities of the image list functions and processing the WM_MOUSEMOVE and WM_LBUTTONUP (or WM_RBUTTONUP) messages sent to the parent window after the drag operation has begun. For more information, see Dragging a Tree-View Item.

If items in a tree-view control are to be the targets of drag-and-drop operations, you need to know when the mouse pointer is on a target item. You can find out by using the TVM_HITTEST message. You specify the address of a TVHITTESTINFO structure that contains the current coordinates of the mouse pointer. When the SendMessage function returns, the structure contains a flag indicating the location of the mouse pointer relative to the tree-view control. If the pointer is over an item in the tree-view control, the structure contains the handle to the item as well.

You can indicate that an item is the target of a drag-and-drop operation by using the TVM_SETITEM message to set the state to the TVIS_DROPHILITED value. An item that has this state is drawn in the style used to indicate a drag-and-drop target.

About Tree-View Control Notification Messages
A tree-view control sends the following notification messages to its parent window in the form of WM_NOTIFY messages.

Notification Description
TVN_BEGINDRAG Signals the start of a drag-and-drop operation.
TVN_BEGINLABELEDIT Signals the start of in-place label editing.
TVN_BEGINRDRAG Signals that the right mouse button has started a drag-and-drop operation.

292
10 апреля 2006 года
Matush
726 / / 14.01.2004
Цитата:
Originally posted by vitaly2003s
Посмотри в сторону TVN_BEGINDRAG,LVN_BEGINDRAG.

Вот немного из MSDN:
..............



Это все хорошо. Но не это суть дела.
Отловить момент когда начали тянуть и куда притянули не проблема. Меня интересует реализация самого D&D. То есть как передать перетягиваемый объект и т.д.?
перетягиваю я из списка в дерево.
MSDN говорит что надо юзать COleDropTerget и COleDropSource. Меня пока интересует как это все вместе склепать.

398
10 апреля 2006 года
Alexandoros
630 / / 21.10.2005
Цитата:
Originally posted by Matush
Это все хорошо. Но не это суть дела.
Отловить момент когда начали тянуть и куда притянули не проблема. Меня интересует реализация самого D&D. То есть как передать перетягиваемый объект и т.д.?
перетягиваю я из списка в дерево.
MSDN говорит что надо юзать COleDropTerget и COleDropSource. Меня пока интересует как это все вместе склепать.



Я еще не юзал - это все automation i ole. В мсдн статейка некислая по автоматии, чти. :)

292
11 апреля 2006 года
Matush
726 / / 14.01.2004
Цитата:
Originally posted by Alexandoros
Я еще не юзал - это все automation i ole. В мсдн статейка некислая по автоматии, чти. :)


Уже разобрался.
Кому интересно, мне помогло вот это:
http://www.codeproject.com/clipboard/mfcdroptarget.asp

Реклама на сайте | Обмен ссылками | Ссылки | Экспорт (RSS) | Контакты
Добавить статью | Добавить исходник | Добавить хостинг-провайдера | Добавить сайт в каталог