class CGXGridDropTarget: public COleDropTarget

A CGXGridDropTarget object provides the communication mechanism between a grid (either CView or CWnd) and the OLE libraries. Creating an object of this class allows a window to accept data through the OLE drag-and-drop mechanism.

Objective Grid 6.1 introduced a new method that simplifies the registration of a grid as drop target compared to the steps necessary with Objective Grid version 6.0 or earlier. There is no need for you to learn details about the CGXGridDropTarget class any more.

Simply call

   EnableOleDropTarget();

at grid initialization time.

If you want to customize the OLE Dnd behavior you can pass a combination of flags as parameter.

Example:

   EnableOleDropTarget(GX_DNDEGDESCROLL | GX_DNDAUTOSCROLL | GX_DNDTEXT | GX_DNDSTYLES);

Old Approach

Objective Grid will continue to support the old approach in future release. There is no need to rewrite existing applications.

Here is how the old approach worked:

To get a window to accept drop commands, you should first create an object of the CGXGridDropTarget class, and then call the Register function with a pointer to the desired CGXGridCore object as the only parameter. The CGXGridCore object must be multiply-derived both from CWnd and CGXGridCore.

Here is an example of how to register the grid as drop target:

a) Embed a CGXGridDropTarget in your derived grid class

class CMyGridView
{
  ...
  CGXGridDropTarget m_objDndDropTarget;
   ...
};

b) Call CGXGridDropTarget::Register at initialization of grid

int CMyGridView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   if (CGXGridView::OnCreate(lpCreateStruct) == -1)
      return -1;
#if _MFC_VER >= 0x0400
   // Enable grid to be used as data source
   EnableOleDataSource();
   // Register the grid as drop target
   VERIFY(m_objDndDropTarget.Register(this));
endif
}

You might also embed the CGXGridDropTarget object into a parent dialog class and call m_objDndDropTarget.Register(&m_wndGrid) for an embedded grid window, where m_wndGrid should be the grid window object.

Example:

BOOL CSample1Dialog::OnInitDialog()
{
   CDialog::OnInitDialog();
   m_wndGrid.SubclassDlgItem(IDC_GRIDWND5, this);
   m_wndGrid.Initialize();
#if _MFC_VER >= 0x0400
   // Enable grid to be used as data source
   m_wndGrid.EnableOleDataSource();
   // Register the grid as drop target
   VERIFY(m_objDndDropTarget.Register(&m_wndGrid));
#endif
   return TRUE;  // return TRUE  unless you set the focus to a control
}

#include <gxall.h>

See Also

 CGXGridCore::EnableOleDataSource

CGXGridDropTarget

 Class Members