Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Initiating a File DragDrop

Posted on 1998-11-29
5
Medium Priority
?
231 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 200 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

636 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