$_$_TABLE_MIN_COLUMN_SEPARATION 2 $_$_TITLE Jaf's crib sheet for adding drag and drop to a Dialog $_$_CHANGE_POLICY background colour : FEF4CF $_$_CHANGE_POLICY background image : ../../pics/wpaper.gif $_$_CHANGE_POLICY unvisited link colour : red $_$_CHANGE_POLICY text colour : 800040 Introduction ------------ This is a crib sheet for how to add drag and drop to a dialog. It documents the steps I found necessary. Note, this isn't a tutorial, just a collection in one place of all the information required, you should check your documentation for full details of the methods sketched out here (especially to confirm their argument lists). I first wrestled with these issues when developing AscToHTM (http://www.jafsoft.com/asctohtm/) the text to HTML converter used to generate this HTML page from this [[SOURCE_FILE]]. $_$_CONTENTS_LIST Dragging Files -------------- Dragging Files can be supported relatively easily as follows - Add a OnDropFiles(HDROP hDropInfo) handler to your Dialog. You'll probably have to add this manually, as ClassWizard doesn't seen to support the WM_DROPFILES message for dialogs. Make the following changes 1) In your .h file add the OnDropFiles to the AFX_MSG section // Generated message map functions //{{AFX_MSG(A2hDialog) ... afx_msg void OnDropFiles(HDROP hDropInfo); ... //}}AFX_MSG DECLARE_MESSAGE_MAP() 2) In your .cpp file add the ON_WM_DROPFILES() handler to the AFX_MSG_MAP section BEGIN_MESSAGE_MAP(MyDialog, CDialog) //{{AFX_MSG_MAP(MyDialog) ... ON_WM_DROPFILES() ... //}}AFX_MSG_MAP END_MESSAGE_MAP() Strangely, after doing (1) and (2) the results become visible in the ClassWizard. 3) Use ClassWizard to add an OnCreate() handler to your dialog. in this add the call this->DragAcceptFiles(TRUE); This enables Drag and drop of files on your Dialog's window. You can check this by dragging files over your Window. If the cursor is a "no entry" sign (circle with a line through it) it's not working. If the cursor changes to a file/folder icon with a "+" on it, you're in business. 4) Manually add the OnDropFiles method to look something as follows :- $_$_BEGIN_CODE void MyDialog::OnDropFiles(HDROP hDropInfo) { HDROP m_hDropInfo = hDropInfo; CString Filename; if (m_hDropInfo) { int iFiles = DragQueryFile(m_hDropInfo, (UINT)-1, NULL, 0); for (int i=0; i