The CExtGridBaseWnd::OnGbwDataDndDo()
virtual method is invoked in CExtGridWnd
, CExtTreeGridWnd
and CExtReportGridWnd
windows when the user starts drag-n-dropping. You need to derive a class from one of these classes and override this method, and the following virtual methods:
1) The CExtGridBaseWnd::OnGbwDataDndIsAllowed()
virtual method should be overridden and return true
value to enable the event when drag-n-drop starts in the grid window.
2) The CExtGridBaseWnd::OnGbwDataDndCanStart(
)virtual method should be overridden if you want to disable drag-n-drop for particular data cells.
The drag-n-drop for the property grid control is a bit different than for grids listed above because the CExtPropertyGridCtrl
class is not derived from those classes. The CExtPropertyGridCtrl
class is a container for one or more tree grid windows displaying property values and some other controls like a toolbar, a combo box and a tip bar. The tree grids in the property grid control are based on the CExtPropertyGridWnd
class which is derived from CExtTreeGridWnd
. By default, the two tree grids are created: CExtPropertyGridWndCategorized
and CExtPropertyGridWndSorted
. If you need to handle drag-n-drop events in these grids, then you should override the CExtPropertyGridCtrl::OnPgcCreateGrids()
virtual method. Your method should be similar to original listed below, but it should create your own CExtPropertyGridWndCategorized
-derived and CExtPropertyGridWndSorted
-derived classes:
bool CExtPropertyGridCtrl::OnPgcCreateGrids()
{
ASSERT_VALID( this );
try
{
CExtPropertyGridWndCategorized * pGridCategorized =
new CExtPropertyGridWndCategorized( this );
pGridCategorized->m_bAutoDeleteWindow = true;
if( ! pGridCategorized->Create(
this,
__EXT_MFC_ID_PROPERTY_GRID_CATEGORIZED,
true
)
)
{
ASSERT( FALSE );
throw __EXT_MFC_ID_PROPERTY_GRID_CATEGORIZED;
}
CExtPropertyGridWndSorted * pGridSorted =
new CExtPropertyGridWndSorted( this );
pGridSorted->m_bAutoDeleteWindow = true;
if( ! pGridSorted->Create(
this,
__EXT_MFC_ID_PROPERTY_GRID_SORTED
)
)
{
ASSERT( FALSE );
throw __EXT_MFC_ID_PROPERTY_GRID_SORTED;
}
}
catch( ... )
{
return false;
}
return true;
}
Your tree grids should handle drag-n-drop events like described above. You should use the
CExtPropertyGridWnd::PropertyItemToTreeItem()
and
CExtPropertyGridWnd::PropertyItemToTreeItem()
methods for conversion between property category/value pointers and
HTREEITEM
handles that are used by the
CExtTreeGridWnd
class methods. You should use the
CExtTreeGridWnd::ItemGetByVisibleRowIndex()
and
CExtTreeGridWnd::ItemGetVisibleIndexOf()
methods for conversion between
HTREEITEM
handles and plain row indices that are used by the
CExtGridWnd
class methods. The
CExtTreeGridWnd::ItemGetVisibleIndexOf()
method returns a negative value if the specified
HTREEITEM
row handle corresponds to the tree row which have collapsed parent row.