Click to See Complete Forum and Search --> : ActiveX: MSDataGrid problem (bug?)


Percy
June 4th, 1999, 02:51 AM
I want to use the MSDataGrid in a new ActiveX control and have a strange problem.

Since it's not possible to subclass any ActiveX control like the following example using the standard windows button control:

BOOL CSampleCtrl::PreCreateWindow( CREATESTRUCT& cs )
{
cs.lpszClass = _T("BUTTON");
return COleControl::PreCreateWindow(cs);
}

BOOL CSampleCtrl::IsSubclassedControl( )
{
return TRUE;
}

void CSampleCtrl::OnDraw( CDC* pdc, const CRect& rcBounds,
const CRect& rcInvalid )
{
DoSuperclassPaint( pdc, rcBounds );
}



So I've tried this way:

- generate wrapper classes for all MSDataGrid classes
- use a member MSDataGrid wrapper class in my control (m_DataGrid)
- creating and resizing the control:

int CMyDataGridCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;

m_DataGrid.Create(NULL, WS_VISIBLE, CRect(0, 0, 10, 10), this, 0);

return 0;
}

void CMyDataGridCtrl::OnSize(UINT nType, int cx, int cy)
{
COleControl::OnSize(nType, cx, cy);

m_DataGrid.MoveWindow(CRect(0, 0, cx, cy));
}



Everything works fine except the navigation inside the embedded grid! It's not possible to change the row and column with the arrow keys. Setting the property m_DataGrid.SetAllowArrows(true) does not help either. Is it a bug or a feature? ;)

Thanks in advance
Percy