Solved

Initiating a File DragDrop

Posted on 1998-11-29
5
225 Views
Last Modified: 2013-11-20
Given a tree control or such, How do I initiate a simple file drag drop? there is a simple interface at the drop end, but i can't seem to find an easy begin-drag interface point.

any suggestions?

thanks,
Gavin.
0
Comment
Question by:mrpinko
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
Bridge earned 100 total points
ID: 1325490
afx_msg void OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult);
      
ON_NOTIFY_REFLECT(TVN_BEGINDRAG, OnBegindrag)

void CHierachyEditorView::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
{
  NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  m_htDrag = pNMTreeView->itemNew.hItem;

  int nImageNumberN, nImageNumberS;      
  GetTreeCtrl().GetItemImage( m_htDrag, nImageNumberN, nImageNumberS );

  CPoint point;
  GetCursorPos( &point );
  ScreenToClient( &point );

  ShowCursor(FALSE);
  SetCapture();
      
  // Start the drag operation.
  //m_pImageList->SetDragCursorImage( nImageNumberN,CPoint(10,10) );
  m_pImageList->BeginDrag(nImageNumberN,CPoint(10,10));
  m_pImageList->DragEnter(this,point);

  // Hide the mouse cursor, and direct mouse input to the
  // parent window.
  m_bDragging = TRUE;
      
  *pResult = 0;
}

0
 

Author Comment

by:mrpinko
ID: 1325491
OK.. i see. this generates a crsor image which can be moved on mouse moves.
thanks!

to be a little more specific,
with dragging and dropping a *file*, eg. from the windows explorer to my application
CTreeCtrl method  "OnDropFiles" suplies me with the path to the dropped file. How do i go about doing the same thing when transferring a file back the other way? (ie. is there an API interface with which i can define the current drag-and-drop operation as a file drag? and supply the path?

mr pinko.
0
 

Author Comment

by:mrpinko
ID: 1325492
OK.. i see. this generates a crsor image which can be moved on mouse moves.
thanks!

to be a little more specific,
with dragging and dropping a *file*, eg. from the windows explorer to my application
CTreeCtrl method  "OnDropFiles" suplies me with the path to the dropped file. How do i go about doing the same thing when transferring a file back the other way? (ie. is there an API interface with which i can define the current drag-and-drop operation as a file drag? and supply the path?

mr pinko.
0
 
LVL 1

Expert Comment

by:Bridge
ID: 1325493
Use the clipboard format CF_HDROP with the DROPFILES structure.
0
 

Author Comment

by:mrpinko
ID: 1325494
hi bridge, thanks for the comments so far.

i can see how the clipboard can be used to transfer data from one window in my application to another *in my applicataion* using the code given above.
however, this does not help (me at least) in the case where the windows explorer or desktop or other application is the target of the file drag!

it seems to me that i should be able to place the file names on the clipboard (or whatever) and then initiate a "kernel-controlled" or "system-wide" file drag. In such a case, the OS sends a WM_FILEDROP message to teh target window at the correct time.

how are inter-application file drops achieved? is my intuition totally flawed?

thanks,
Gavin.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question