These are the points you have to take into account
- The DragAcceptFiles function registers whether a window accepts dropped files
- The WM_DROPFILES message is sent when the user releases the left mouse button while the cursor is in the window of an application that has registered itself as a recipient of dropped files.
In the windows API documentation you can find examples if you look for these topics.
This is the function I used to open files. Note that the functions with :: are defined in my program. use your functions instead. Don't forget to include at the beginning of the program
PHP Code:
DragAcceptFiles(hWnd, TRUE); // Prepare the application to accept dragged files
BOOL Frame::OnDropFiles(HINSTANCE hInst, HWND hWnd, WPARAM wParam)
{
HDROP hDrop = (HDROP)wParam;
POINT pt;
char szFileName[MAX_PATH];
DragQueryPoint(hDrop, &pt);
if (DragQueryFile(hDrop, 0xFFFFFFFF, 0, 0) > 1) // Accept only 1 dropped file
return Error::ProcessWarning(hWnd, IDS_DRAGONEFILE);
// If there is a previous experiment close it and open a new one
if (TreeView_GetCount(GetDlgItem(hWnd, ID_TREEVIEW)))
if (!Frame::CloseExperiment(hWnd))
return FALSE;
// Get file name and open it
DragQueryFile(hDrop, 0, szFileName, sizeof(szFileName));
Frame::OpenExperiment(hInst, hWnd, szFileName);
// Free memory when done
DragFinish(hDrop);
return FALSE;
}