Objective Grid: Non-OLE drag and drop

Article ID: 329
Last updated: 07 Jun, 2018
Article ID: 329
Last updated: 07 Jun, 2018
Revision: 3
Views: 2296
Posted: 11 Jan, 2001
by Meltreger B.
Updated: 07 Jun, 2018
by Meltreger B.

Problem


Does OG support drag and drop from one cell to another (I don't want to use OLE Drag and Drop)?


Cause



Action


Drag and drop from one cell to another is possible even if you don't want to use OLE Drag and Drop. Here are some steps you have to follow:

First, you should disable selecting cells, for example:

// disable selecting cells
GetParam( )->EnableSelection(GX_SELNONE);

Next, you should override OnLButtonHitRowCol( ). This virtual method is called when the user clicks on a cell and drags the mouse cursor.

BOOL CGridSampleView::OnLButtonHitRowCol(ROWCOL nHitRow, ROWCOL nHitCol, ROWCOL nDragRow, ROWCOL nDragCol, CPoint point, UINT flags, WORD nHitState)
{
if (!CMyGridView::OnLButtonHitRowCol(nHitRow, nHitCol, nDragRow, nDragCol, point, flags, nHitState))
return FALSE;
// determine style and control of the cell
const CGXStyle& style = LookupStyleRowCol(nHitRow, nHitCol);
CGXControl* pControl = GetRegisteredControl(style.GetControl( ));

if (nHitRow > 0 && nHitCol > 0)
{

if (nHitState & GX_HITSTART)
{
}
else if (nHitState & GX_HITMOVE)
{
if (m_nDragRow != nHitRow || nDragCol != nHitCol)
{
// display drag-cursor
SetGridCursor(GX_IDC_SELDRAG);
}
else
{
// reset cursor
SetGridCursor(0);
}
}
else if (nHitState & GX_HITEND)
{
if (m_nDragRow != nHitRow || nDragCol != nHitCol)
{
// Here, you should provide your code
// to execute the dragging-operation
}

// reset cursor
SetGridCursor(0);

}
}

return TRUE;

}

You can also take a look at the "Headers"-Page in gridapp (source is in gridsvw7.cpp), this sample allows dragging columns by clicking on a column header and then dragging the mouse.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 329
Last updated: 07 Jun, 2018
Revision: 3
Views: 2296
Posted: 11 Jan, 2001 by Meltreger B.
Updated: 07 Jun, 2018 by Meltreger B.

Others in this category