Solved

Initiating a File DragDrop

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

18 Experts available now in Live!

Get 1:1 Help Now