Here is a simple method to have a Drag and Drop feature in your dialog based applications. To provide Drag and Drop we have a Windows Message Handler called
WM_DROPFILES. Handle this message through the
ON_MESSAGE message map to capture the dropped files.
Now it is time to handle the
WM_DROPFILES messages through a user defined method. The function prototype should be like this:
LRESULT OnDropFiles(WPARAM wParam,LPARAM lParam);
Finally we have a function to capture the drop events.
wParam is a handle to the
HDROP structure describing the dropped files.
To get info about the dropped file, i.e., the file name used:
So now we have done all possible coding in our dialog based application to handle the Drag & Drop feature. But still it is handicapped.
Handling the Drop event is not enough to ensure the Drag & Drop feature. We need to register our window to accept the dropped file using:
Good... That's all, and we have done well!
I added one more feature in this sample, i.e., moving our dialog by clicking on anywhere on the window. This can be done by posting the
HTCAPTION handle this statement in