Solved

Initiating a File DragDrop

Posted on 1998-11-29
5
224 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 181
Perl Awk Need Help 3 116
List out all word 7 285
fizzArray2 challenge 1 78
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

815 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now