Enabling Drag-and-Drop without Oledigitally Urs (View Profile) May 21, 2003
Source: http://www.codeguru.com/cpp/cpp/cpp_mfc/dragdrop/article.php/c4059/
The drag-and-drop can be obtained in two ways; the first is OLE and the second is using the MFC MFC supports the functionality of drag-and-drop without using OLE To enable drag-and-drop in your application,.. You'll Have to Perform The Following Tasks:
The CWnd :: DragAcceptFiles () enables you to accept the drag-and-drop functionality for your application. The only parameter to the function is of the BOOL type and which, by default, is set to FALSE to disable the drag-and- . drop functionality Setting it to TRUE will enable your application to handle WM_DROPFILES message for the CWND class The DragAcceptFiles function can be called of any CWnd derived class;. handling the WM_DROPFILES will enable your application for drag-and-drop.
The Steps Involved Are The Following (I'm Writing The Code Segment for an SDI Application):
Go in the CMainFrame :: OnCreate function of your SDI application and make a call to DragAcceptFiles: int CMainFrame :: OnCreate (LPCREATESTRUCT lpCreateStruct) {// MFC code goes here DragAcceptFile (true) // call the Drag Accept files // rest of MFC code generated by ClassWizard} you must keep in mind that you must call this function after the CWnd object has been created Map the WM_DROPFILES message for your CMainFrame class and modify the code like the following:. void CMainFrame :: OnDropFiles (HDROP hDropInfo) {Uint i = 0; uint nfiles = :: DragQueryfile (hdropinfo, (uint) -1, null, 0); for (i = 0; i Danish Qamar is a student of Computer Sciences in Lahore, Pakistan. He's been developing Web applications for three years and started working with Visual C in February, 2002. Other interests includes playing games, messing up 3d models integration in OpenGL, and is a badminton Freak. He Can Be Reached At: Sahil_2@hotmail.com or chicken_IN_THE_KITCHEN@yahoo.com