Dragging between two CTreeCtrl in a Dialog Box
abramsd@RADES.HILL.AF.MIL Friday, September 06, 1996 Environment: MSVC 4.0, Windows 95, IBM PC I'm having a hard time figuring out how to drag an item from a CTreeCtrl in a dialog to another CTreeCtrl in the same dialog. When I leave the rect of the first CTreeCtrl the drag item disappears. Doug Abrams
Quang Ngo -- quang@psnw.com Saturday, September 07, 1996 [Mini-digest: 2 responses] Doug, When you call the following function to enter the drag state, be sure to pass NULL to pWndLock that way the owner of the dragging image is the desktop. In this case, you'll always see your dragging image as you drag it. static BOOL DragEnter( CWnd* pWndLock, CPoint point ); -Quang ---------- > From: abramsd@RADES.HILL.AF.MIL > To: mfc-l@netcom.com > Subject: Dragging between two CTreeCtrl in a Dialog Box > Date: Friday, September 06, 1996 7:16 AM > > > Environment: MSVC 4.0, Windows 95, IBM PC > > I'm having a hard time figuring out how to drag an item from a > CTreeCtrl in a dialog to another CTreeCtrl in the same dialog. > > When I leave the rect of the first CTreeCtrl the drag item disappears. > > Doug Abrams > -----From: Jim LeavittDoug: Log into www.microsoft.com and search their site for MFCDRAG. The sample does exactly what you're trying to do. Jim Leavitt
Niels Ull Jacobsen -- nuj@kruger.dk Monday, September 09, 1996 At 07:16 06-09-96 MST, you wrote: > =20 > Environment: MSVC 4.0, Windows 95, IBM PC > =20 > I'm having a hard time figuring out how to drag an item from a=20 > CTreeCtrl in a dialog to another CTreeCtrl in the same dialog. > =20 > When I leave the rect of the first CTreeCtrl the drag item disappea= rs. Remember to do a m_pimagelist->DragEnter(this, ptAction); in the dialog. This will make the dragged item "leave" the tree control and "enter" the = dialog. Here's some (shortened) code from my application (names changed to unclut= ter the code). I hope you'll find it useful. void CSomeDialog::OnBegindragSomeTree(NMHDR* pNMHDR, LRESULT* pResult)=20 { NM_TREEVIEW* pNMTreeView =3D (NM_TREEVIEW*)pNMHDR; // TODO: Add your control notification handler code here =09 ASSERT(!m_bDragging); =09 CPoint ptTree =3D pNMTreeView->ptDrag; =09 UINT nFlags; HTREEITEM hItem =3D m_SomeTree.HitTest(ptTree, &nFlags); if (hItem =3D=3D NULL) { *pResult =3D 0; return; }; // some internals recording information about which item is being dragged left out here m_pImageList =3D m_SomeTree.CreateDragImage(hItem); // get the image li= st for dragging m_bDragging =3D TRUE; =09 CPoint ptAction; GetCursorPos(&ptAction); ScreenToClient(&ptAction); TRACE("ptAction =3D (%d, %d)\n", ptAction.x, ptAction.y); ASSERT_VALID(m_pimagelist); m_pimagelist->DragShowNolock(TRUE); m_pimagelist->SetDragCursorImage(0, CPoint(0, 0)); m_pimagelist->BeginDrag(0, CPoint(0,0)); m_pimagelist->DragMove(ptAction); m_pimagelist->DragEnter(this, ptAction); SetCapture(); *pResult =3D 1; } Niels Ull Jacobsen [MVP], Kr=FCger A/S (nuj@kruger.dk) Everything stated herein is THE OFFICIAL POLICY of the entire Kruger=20 group and should be taken as legally binding in every respect.=20 Pigs will grow wings and fly.
| Вернуться в корень Архива |