Professional User Interface Suite, Copyright FOSS Software Inc. Help Published with Permission.

You can implement drag-and-drop for any grid derived from CExtGridWnd. Here are some key points to keep in mind:

  •    To enable drag-and-drop functionality, override the CExtGridWnd::OnGbwDataDndIsAllowed() virtual method: it should simply return true;
  •    You can suppress drag-and-drop for a particular cell(s) by overriding CExtGridWnd::OnGbwDataDndCanStart(): it should return false when appropriate;
  •    Implement your drag-and-drop algorithm itself in the CExtGridWnd::OnGbwDataDndDo() virtual method;
  •    Implement the standard IDropSource and IDropTarget interfaces so that you can catch drag-and-drop events in your application. You should implement IDropTarget whenever you want: your grid, other window, or even some other application.

You can see the implementation details in the FormEditor sample, where the user can drag-and-drop items from the toolbox onto a form.