Editor's note: this technique requires LB3 and uses callbacks. Callbacks are explained in detail above. The API calls for drag 'n' drop are also explained in detail above. This technique also requires the wmliberty.dll by Brent Thorn, which will be spotlighted in a future newsletter. This DLL is still under development. An early version of the DLL is supplied with this newsletter to be used with the drag 'n' drop demos.
LB Drag n Drop
by Mitchell Kotler firstname.lastname@example.org
Version of LB required for this Article:
Files that go with this Article:
(These all require the WMLiberty.dll to run)
(v1.0 of DLL included by permission of Brent Thorn)
This article shows how Drag n Drop works, and how to implement it in LB. The simplest sample, dnd1.bas, will simply display the path of the file dragged onto it. Open dnd1.bas, take a look at the code to see how it works, and run it. Now open Explorer, click on a file, and drag it to the gray area of the window. If the window is hidden by Explorer, drag the file to the taskbar (at the bottom of your screen) over the title of your window. It should be brought to the front after a second, where you can continue your drag and drop. after dropping the file you should see the path of the file you just dropped.
Now, open dnd2.bas. Look over the changes in the code. This file will accept multiple files, all dragged on dropped at once. Select multiple files in Explorer by holding down the shift or control key and click on the files you want to select. Now, with them all selected, drag them over to the window. All the paths shoud appear in the listbox.
Dnd3.bas will simply open any file you drag onto it in the text window. You can try it out. Dnd4.bas will draw any bmp you drag onto it, at the point that you drop it. Test this one out with the bmp's that come with LB. Also be sure to look at the changes in the code for this one.
If you need any help with drag n drop code in your applications, I'll be more then willing to help. Just post it to the Liberty Basic or LBExp (this is pretty advanced stuff) group, or e-mail me, and I'll try to help you out. Have fun, and I hope to see this used in your programs!