You need to derrive you class from wxDropTarget... There you need to override some functions: OnData, OnDrop... ...MyDropTarget : public wxDropTarget...
then you need to make you window, able to receive drops on it... i do this just after i create a window:
MyDropTarget * dropTarget = new MyDropTarget(this); dropTarget->SetDataObject(new wxFileDataObject()); myDnDTargetWindow->SetDropTarget(dropTarget); Now in MyDropTarget::OnData you can do whatever you want with the data received...
If you want to drag something you need to create a DropSource
wxFileDataObject my_data(&data); CDropSource dragSource( this ); dragSource.SetData( my_data ); dragSource.DoDragDrop( TRUE ); Please note that this code might not be very correct... It's just what i came up to for my project :) Also take a look at DnD sample from wxWidgets samples.
It's a little too much in that sample, but you can still learn from it... |