Solved

Initiating a File DragDrop

Posted on 1998-11-29
5
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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 this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

691 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