CTreeView Drag and Drop...
Andy Morrical -- Andy_Morrical@ncs.com
Monday, February 17, 1997
Environment : Visual C++ 4.2b, Windows 95, Windows NT 4.0
(Actually this is for a friend of mine who doesn't have access.)
I'm using MSVC++ v4.2 and using the CTreeView. I'm having trouble
getting my CTreeView to properly support dragging and dropping of
items in the tree. I know I have to use the CreateDragImage,
BeginDrag, DragMove, and EndDrag but I just can't get the proper
combination of settings.
I've reviewed the MS sample code (which is SDK, not MFC) and still
can't figure it out. Does someone have any code snippets of MFC
CTreeView code which allows drag and drop (and displays the 'dragging
bitmap image' when dragging).
Help!
LeRoy Baxter -- lbaxter@transport.com
Tuesday, February 18, 1997
[Mini-digest: 3 responses]
I recently did this (drag and drop on a tree). I found the SDK examples pretty
worthless. The best (and only working) sample comes with VC++. Find it
under Samples -> MFC -> General -> Cmnctrls (specifically; mtreectl.cpp/h)
Email me direct if you can't find it.
-----Original Message-----
From: Andy Morrical [SMTP:Andy_Morrical@ncs.com]
Sent: Monday, February 17, 1997 1:56 PM
To: mfc-l@netcom.com
Subject: CTreeView Drag and Drop...
Environment : Visual C++ 4.2b, Windows 95, Windows NT 4.0
(Actually this is for a friend of mine who doesn't have access.)
I'm using MSVC++ v4.2 and using the CTreeView. I'm having trouble
getting my CTreeView to properly support dragging and dropping of
items in the tree. I know I have to use the CreateDragImage,
BeginDrag, DragMove, and EndDrag but I just can't get the proper
combination of settings.
I've reviewed the MS sample code (which is SDK, not MFC) and still
can't figure it out. Does someone have any code snippets of MFC
CTreeView code which allows drag and drop (and displays the 'dragging
bitmap image' when dragging).
Help!
-----From: Paul.B.Folbrecht@jci.com
There is a sample of doing drag and drop with a CTreeCtrl in the MFC sample
CommCtrls. The code for doing it in a CTreeView is identicaly, with of course
the necessary calls to GetTreeCtrl().
Paul Folbrecht
______________________________ Reply Separator _________________________________
Subject: CTreeView Drag and Drop...
Author: Andy_Morrical@ncs.com at Mailhub
Date: 2/18/97 3:52 AM
Environment : Visual C++ 4.2b, Windows 95, Windows NT 4.0
(Actually this is for a friend of mine who doesn't have access.)
I'm using MSVC++ v4.2 and using the CTreeView. I'm having trouble
getting my CTreeView to properly support dragging and dropping of
items in the tree. I know I have to use the CreateDragImage,
BeginDrag, DragMove, and EndDrag but I just can't get the proper
combination of settings.
I've reviewed the MS sample code (which is SDK, not MFC) and still
can't figure it out. Does someone have any code snippets of MFC
CTreeView code which allows drag and drop (and displays the 'dragging
bitmap image' when dragging).
Help!
-----From: Joe Willcoxson
At 03:56 PM 2/17/97 CST, you wrote:
> Environment : Visual C++ 4.2b, Windows 95, Windows NT 4.0
>
> (Actually this is for a friend of mine who doesn't have access.)
>
> I'm using MSVC++ v4.2 and using the CTreeView. I'm having trouble
> getting my CTreeView to properly support dragging and dropping of
> items in the tree. I know I have to use the CreateDragImage,
> BeginDrag, DragMove, and EndDrag but I just can't get the proper
> combination of settings.
>
> I've reviewed the MS sample code (which is SDK, not MFC) and still
> can't figure it out. Does someone have any code snippets of MFC
> CTreeView code which allows drag and drop (and displays the 'dragging
> bitmap image' when dragging).
>
> Help!
See the MFC sample cmnctrls at \msdev\mfc\samples\general.
--
Gloria in excelsius Deo
Joe Willcoxson (joew@statsoft.com), Senior Software Engineer
Visit us: http://www.statsoft.com, Visit me: http://users.aol.com/chinajoe
#define STD_DISCLAIMER "I speak only for myself"
__cplusplus spoken here;
Michael Johnson -- michael@technicon.com
Tuesday, February 18, 1997
[Mini-digest: 2 responses]
For an an MFC solution I used COleDataSource class. You have to define
the way you object is being stored in the same manner as coping to the
clipboard. Text could be fine for a tree item unless you something
behind. I used an IStorage to represent my tree item and its data.
First I made a copy then stored it in the object.
LPLOCKBYTES lpLockBytes;
SCODE sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
sc =
::StgCreateDocfileOnILockBytes(lpLockBytes,STGM_SHARE_EXCLUSIVE|STGM_CRE
ATE|STGM_READWRITE, 0, &lpStorage);
//copy item storage to clipboard storage
origStorage->CopyTo(NULL,NULL,NULL,lpStorage);
lpLockBytes->Release();
// save the object into the clipboard
STGMEDIUM stgMedium;
stgMedium.tymed = TYMED_ISTORAGE;
stgMedium.pstg = lpStorage;
stgMedium.pUnkForRelease = NULL;
UINT cf = RegisterClipboardFormat (CF_EMBEDDEDOBJECT);
dataSource->CacheData (cf, &stgMedium, NULL);
then I called this to start a modal drag loop
DROPEFFECT
result=dataSource->DoDragDrop(DROPEFFECT_COPY|DROPEFFECT_MOVE,
&rect,NULL );
on the drop side use a COleDataObject to retrieve the data
OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
{
m_dataDropObject= new COleDataObject;
m_dataDropObject->Attach(pDataObject->GetIDataObject(FALSE),TRUE);
...
STGMEDIUM stgMediumReturn;
UINT cf = RegisterClipboardFormat (CF_EMBEDDEDOBJECT);
BOOL success = pDataObject->GetData (cf, &stgMediumReturn, NULL);
the storage is in stgMediumReturn.pstg. This might be more than you are
looking for.
mike
>-----Original Message-----
>From: Andy Morrical [SMTP:Andy_Morrical@ncs.com]
>Sent: Monday, February 17, 1997 9:56 PM
>To: mfc-l@netcom.com
>Subject: CTreeView Drag and Drop...
>
> Environment : Visual C++ 4.2b, Windows 95, Windows NT 4.0
>
> (Actually this is for a friend of mine who doesn't have access.)
>
> I'm using MSVC++ v4.2 and using the CTreeView. I'm having trouble
> getting my CTreeView to properly support dragging and dropping of
> items in the tree. I know I have to use the CreateDragImage,
> BeginDrag, DragMove, and EndDrag but I just can't get the proper
> combination of settings.
>
> I've reviewed the MS sample code (which is SDK, not MFC) and still
> can't figure it out. Does someone have any code snippets of MFC
> CTreeView code which allows drag and drop (and displays the 'dragging
> bitmap image' when dragging).
>
> Help!
>
-----From: jtalkar@optika.com (Jeremiah Talkar)
I referred to the "MFCDRAG" sample that is available from the Microsoft
VC++ Knowledge Base articles
(http://www.microsoft.com/kb/articles/q148/7/38.htm ).
I can forward this to you if you are unable to get hold of it. This self
-extracting executable is only 36KB.
You also need to ensure that you have not accidently set the
TVS_DISABLEDRAGDROP style when creating your CTreeView derived class.
-----Original Message-----
From: Andy Morrical
Sent: Monday, February 17, 1997 3:56 PM
To: mfc-l@netcom.com
Subject: CTreeView Drag and Drop...
Environment : Visual C++ 4.2b, Windows 95, Windows NT 4.0
(Actually this is for a friend of mine who doesn't have access.)
I'm using MSVC++ v4.2 and using the CTreeView. I'm having trouble
getting my CTreeView to properly support dragging and dropping of
items in the tree. I know I have to use the CreateDragImage,
BeginDrag, DragMove, and EndDrag but I just can't get the proper
combination of settings.
I've reviewed the MS sample code (which is SDK, not MFC) and still
can't figure it out. Does someone have any code snippets of MFC
CTreeView code which allows drag and drop (and displays the
'dragging
bitmap image' when dragging).
Help!
kukulies@axpn01.fev.de
Wednesday, February 19, 1997
[Mini-digest: 3 responses]
There is an example in ftp.microsoft.com/SoftLib/MSLFILES/dragdrop.exe
Benno
-----From: kukulies@axpn01.fev.de
I am sorry, the address ftp.microsoft.com/Softlib/mslfiles
does not contain the correct sample. The correct address
for an example is:
http://www.microsoft.com/kb/articles/q148/7/38.htm
This examples covers Drag&Drop from treectrl to listctrl and
vice versa.
Benno
-----From: "Anujit Sarkar"
Look for the Cmnctrls sample under samples\mfc\general
----------
> From: Andy Morrical
> To: mfc-l@netcom.com
> Subject: CTreeView Drag and Drop...
> Date: Tuesday, February 18, 1997 3:26 AM
>
> Environment : Visual C++ 4.2b, Windows 95, Windows NT 4.0
>
> (Actually this is for a friend of mine who doesn't have access.)
>
> I'm using MSVC++ v4.2 and using the CTreeView. I'm having trouble
> getting my CTreeView to properly support dragging and dropping of
> items in the tree. I know I have to use the CreateDragImage,
> BeginDrag, DragMove, and EndDrag but I just can't get the proper
> combination of settings.
>
> I've reviewed the MS sample code (which is SDK, not MFC) and still
> can't figure it out. Does someone have any code snippets of MFC
> CTreeView code which allows drag and drop (and displays the
'dragging
> bitmap image' when dragging).
>
> Help!
>
Become an MFC-L member
| Вернуться в корень Архива
|