Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Split View Collapse All
Subject Author Date
Keith Bradbury Jun 8, 2005 - 9:06 AM

for each document, I want to have a split frame with 2 panes. In the top pane, I need to put a grid. The bottom pane is for drawing. How can I do use the grid from prof-uis in the top pane?

Technical Support Jun 9, 2005 - 8:35 AM

You code is correct but the grid window is created with the width and height set to zero, so it is not visible. So, you need just to resize the grid window so that it can stretch to the full view space:

#define IDC_GRID 0x1111
 
BOOL CTest_grid_in_viewView::PreCreateWindow(CREATESTRUCT& cs)
{
      BOOL bPreCreated = CView::PreCreateWindow(cs);
      cs.style |= WS_CLIPSIBLINGS|WS_CLIPCHILDREN;
      return bPreCreated;
}
 
int CTest_grid_in_viewView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
      if (CView::OnCreate(lpCreateStruct) == -1)
            return -1;
      
    if( ! m_wndGrid.Create(
            this,
            CRect(0,0,0,0),
      IDC_GRID
            )
        )
    {
        ASSERT( FALSE );
        return -1;
    }
 
      m_wndGrid.OuterRowCountTopSet( 1L, false );
 
      LPCTSTR arrHdrNames[3];
      INT arrHdrExtents[3];
      
      arrHdrNames[0]    = _T("Column 0");
      arrHdrNames[1]    = _T("Column 1");
      arrHdrNames[2]    = _T("Column 2");
      arrHdrExtents[0]  = 100;
      arrHdrExtents[1]  = 100;
      arrHdrExtents[2]  = 100;
      
      LONG nColCount = sizeof(arrHdrNames) / sizeof(arrHdrNames[0]);
      m_wndGrid.ColumnAdd( nColCount, false );
 
      for( LONG nColNo = 0L; nColNo < nColCount; nColNo++ )
      {
            CExtGridCellHeader * pCell =
                  STATIC_DOWNCAST(
                        CExtGridCellHeader,
                        m_wndGrid.GridCellGetOuterAtTop(
                              nColNo,
                              0L,
                              RUNTIME_CLASS(CExtGridCellHeader)
                        )
                  );
            pCell->ExtentSet( arrHdrExtents[nColNo] );
            pCell->TextSet( arrHdrNames[nColNo] );
      }
      
      CWnd::RepositionBars( 0, 0xFFFF, IDC_GRID );
      
      m_wndGrid.OnSwUpdateScrollBars();
      m_wndGrid.OnSwDoRedraw();
 
      return 0;
}
 
void CTest_grid_in_viewView::OnSize(UINT nType, int cx, int cy) 
{
      CView::OnSize(nType, cx, cy);
 
      if( nType != SIZE_MINIMIZED )
            CWnd::RepositionBars( 0, 0xFFFF, IDC_GRID );
}


Technical Support Jun 8, 2005 - 11:14 AM

Just create a splitter window as usual. Then dynamically create a child grid window in the view that is in the top pane:

if( ! m_wndGrid.Create(
            this, //<-- pointer to the view window, which is in the top pane
            CRect(0,0,0,0),
            IDC_GRID
            )
      )
{
      ASSERT( FALSE );
      return -1;
}

Keith Bradbury Jun 8, 2005 - 8:14 PM

The first step for me is to get the grid to work in a simple view, without worrying about the split pane for now. I did the following but the grid does not show up. Could you tell me what is wrong or provide me with the simplest example just to get the grid to show up in a view. Thanks!

my view class header file:
class CTestGridView : public CView
{
...
public:
    CExtGridWnd m_wndGrid;
...
}

In the view class source file:
int CTestGridView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CView::OnCreate(lpCreateStruct) == -1)
        return -1;

    // TODO: Add your specialized creation code here
    if( ! m_wndGrid.Create(
                this, //<-- pointer to the view window, which is in the top pane
                CRect(0,0,0,0)
                )
        )
    {
        ASSERT( FALSE );
        return -1;
    }
    return 0;
}