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 » CExtGridWnd is Invisible combined with CExtResizableDialog and CExtControlBar!!! Collapse All
Subject Author Date
Nicholas Vezirgiannis Dec 24, 2008 - 5:08 AM

Hello,

I would like to ask you a question regarding the CExtGridWnd object. I am working on VS2005 MFC with profuis 2.8.2.


I have created a class called CProdGridWnd derived from CExtGridWnd. Also I Created a Dialog Template with a Custom control (Class ProfUIS-ScrollItemWindow) which I use to put the grid in.

That works fine on a normal dialog box.

But If I try to use your CExtResizableDialog combined with CExtControlBar to convert this dialog into a dockable window in a document-view MFC project, the grid is invisible. In fact if I put any other control on the form it works fine, but the area of the custom control that includes the grid is just white. The peculiar thing is that other than that the grid works. When clicking randomly on that white area the grid events run and with a double click, an edit box appears with the data of the cell under it to change. When changing it and pressing enter, the OnGridCellInputComplete event runs as it should, but the cell and the data just typed disappear again.


Could you help me make the Grid Control visible again?


I tried to combine 2 of your examples the Dialog View in the SDIDOCVIEW project and the CExtGridWnd in ProfUIS_Controls project. I would like to attach the small test project I created so that you can see the problem. Please send me an email to dbalotis@bsi.gr to send you this project. The code bellow are the most important parts of the test project.


I would appreciate your answer the soonest possible and thank you for your time in advance.


Merry Xmas




<File GridDlg.h>


class CProdGridWnd : public CExtWFF < CExtGridWnd >

{

public:

 CProdGridWnd();

 ~CProdGridWnd();

protected:

 CExtScrollBar m_wndScrollBarH, m_wndScrollBarV;

 virtual CScrollBar * GetScrollBarCtrl( int nBar ) const;

 virtual void PreSubclassWindow();


 virtual void OnGbwFocusChanged(const POINT & ptOldFocus, const POINT & ptNewFocus);


 virtual void OnGridCellInputComplete(CExtGridCell & _cell, LONG nColNo, LONG nRowNo, INT nColType, INT nRowType, HWND hWndInputControl);

};


//////////////////////////////////////////////////////////////////////////////////////////////////




// CGridDlg dialog


class CGridDlg : public CExtResizableDialog //CDialog

{

 DECLARE_DYNAMIC(CGridDlg)


public:

 CProdGridWnd m_wndProdGrid;




 CGridDlg(CWnd* pParent = NULL);   // standard constructor

 virtual ~CGridDlg();


// Dialog Data

 enum { IDD = IDD_RESIZABLE_GRID_DIALOG };


protected:

 virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

 virtual BOOL OnInitDialog();

 afx_msg void OnSysCommand(UINT nID, LPARAM lParam);

 afx_msg void OnPaint();


 DECLARE_MESSAGE_MAP()

};


--------------------------------------------------------------------------------------------------




<part of File GridDlg.cpp>


BOOL CGridDlg::OnInitDialog() // here we fill the grid

{

 CExtResizableDialog::OnInitDialog();

 


 AddAnchor( IDC_GRID, __RDA_LT, __RDA_RB );


 bool bRedraw = true;

 

 m_wndProdGrid.OuterRowCountTopSet( 1L, bRedraw );

 m_wndProdGrid.OuterColumnCountLeftSet( 1L, bRedraw );

 m_wndProdGrid.OuterColumnCountRightSet( 1L, bRedraw );

 m_wndProdGrid.OuterColumnWidthSet( true, 0L, 14 );

 m_wndProdGrid.OuterColumnWidthSet( false, 0L, 14 );


 m_wndProdGrid.NoHideSelectionSet( true, bRedraw );

 m_wndProdGrid.SubtractSelectionAreasSet( true, bRedraw );

 m_wndProdGrid.LbExtSelectionSet( true );

 m_wndProdGrid.GridLinesHorzSet( true, bRedraw );

 m_wndProdGrid.GridLinesVertSet( true, bRedraw );

 m_wndProdGrid.HoverEventsSet( true, true );

 m_wndProdGrid.MultiAreaSelectionSet( false );

 m_wndProdGrid.HoverHighlightSet( true, false, false, false, true, true );


 m_wndProdGrid.SiwModifyStyle(

     (__ESIS_STH_PIXEL|__ESIS_STV_ITEM) // item scroll window styles

   | __EGBS_SFB_CELLS      // selection/focus type

   | __EGBS_RESIZING_CELLS_OUTER   // enable row/column resizing

   | __EGBS_RESIZING_CELLS_INNER   

   | __EGBS_DYNAMIC_RESIZING    // resize rows/columns on-the-fly

   ,

  0,

  bRedraw

  );

 m_wndProdGrid.BseModifyStyleEx(

     __EGBS_BSE_EX_DBLCLK_BEST_FIT_ROW  // do best fit sizing on double clicks over column divider

   | __EGBS_BSE_EX_DBLCLK_BEST_FIT_COLUMN // do best fit sizing on double clicks over row divider

  ,

  __EGWS_BSE_EX_DEFAULT,

  bRedraw

  );

 m_wndProdGrid.SiwModifyStyleEx(

     __EGBS_EX_CELL_TOOLTIPS_INNER

   | __EGBS_EX_CELL_EXPANDING_INNER

   | __EGWS_EX_PM_COLORS

   | __EGBS_EX_CORNER_AREAS_3D   

   ,

  0,

  bRedraw

  );


 CString tempstr;

 LONG nColNo, nColCount = 5;

 m_wndProdGrid.ColumnAdd( nColCount, false );

 for( nColNo = 0L; nColNo < nColCount; nColNo++ )

 {

  CExtGridCellHeader * pCell =

   STATIC_DOWNCAST(

    CExtGridCellHeader,

    m_wndProdGrid.GridCellGetOuterAtTop(

     nColNo,

     0L,

     RUNTIME_CLASS(CExtGridCellHeader)

     )

    );

  tempstr.Format(_T("TestCol%d"), nColNo+1);

  pCell->TextSet( tempstr );

  pCell->ExtentSet( 100 );

  pCell->ModifyStyle( __EGCS_TA_HORZ_LEFT );

  pCell->FontWeightSet( FW_BOLD );

 }




////////////////////////////////// FILL WITH ROWS ///////////////////////////////////////


 bRedraw = true;


 LONG nRowNo, nRowCount = 10;

 m_wndProdGrid.RowAdd( nRowCount, bRedraw );

 for( nRowNo = 0L; nRowNo < nRowCount; nRowNo++ )

 {

  CExtGridCellHeader * pCellLeft =

   STATIC_DOWNCAST(

    CExtGridCellHeader,

    m_wndProdGrid.GridCellGetOuterAtLeft(

     0L,

     nRowNo,

     RUNTIME_CLASS(CExtGridCellHeader)

     )

    );

  pCellLeft->ExtentSet( 20 );

  pCellLeft->ModifyStyle(

   __EGCS_HDR_FOCUS_ARROW_RESERVE_SPACE

    |__EGCS_HDR_FOCUS_ARROW_DISPLAY

    |__EGCS_TA_HORZ_RIGHT

   );

  CExtGridCellHeader * pCellRight =

   STATIC_DOWNCAST(

    CExtGridCellHeader,

    m_wndProdGrid.GridCellGetOuterAtRight(

     0L,

     nRowNo,

     RUNTIME_CLASS(CExtGridCellHeader)

     )

    );

  pCellRight->ModifyStyle(

   __EGCS_HDR_FOCUS_ARROW_RESERVE_SPACE

    |__EGCS_HDR_FOCUS_ARROW_DISPLAY

    |__EGCS_TA_HORZ_RIGHT

   );

 }


 nColCount = 5;

 for( nColNo = 0L; nColNo < nColCount; nColNo++ )

 {

  for( LONG nRowNo = 0L; nRowNo < nRowCount; nRowNo++ )

  {

   if (nColNo != 4)

   {

    CExtGridCellString * pCellString =

     STATIC_DOWNCAST(

      CExtGridCellString,

      m_wndProdGrid.GridCellGet(

       nColNo,

       nRowNo,

       0,

       0,

       RUNTIME_CLASS(CExtGridCellString)

       )

      );

   } else {

    CExtGridCellCheckBox * pCellCheckBox =

     STATIC_DOWNCAST(

      CExtGridCellCheckBox,

      m_wndProdGrid.GridCellGet(

       nColNo,

       nRowNo,

       0,

       0,

       RUNTIME_CLASS(CExtGridCellCheckBox)

       )

      );

   }

  }

 }




//////////////////////////////// FILL WITH TEST DATA ////////////////////////////////////


 CString temp;

 //LONG nRowNo, nRowCount = 10;

 //LONG nColNo, nColCount = 5;


 for( nColNo = 0L; nColNo < nColCount; nColNo++ )

 {

  for( LONG nRowNo = 0L; nRowNo < nRowCount; nRowNo++ )

  {

   if (nColNo != 4)

   {

    CExtGridCellString * pCellString =

     STATIC_DOWNCAST(

      CExtGridCellString,

      m_wndProdGrid.GridCellGet( nColNo, nRowNo )

      );

    temp.Format(_T("Cell %d-%d"), nColNo+1, nRowNo+1);

    pCellString->TextSet( temp );

   } else {

    CExtGridCellCheckBox * pCellCheckBox =

     STATIC_DOWNCAST(

      CExtGridCellCheckBox,

      m_wndProdGrid.GridCellGet( nColNo, nRowNo )

      );

    pCellCheckBox->SetCheck(0);

   }

  }

 }




 return TRUE;  // return TRUE  unless you set the focus to a control

}


--------------------------------------------------------------------------------------------------




<File MainFrm.h>


#include "GridDlg.h"


class CMainFrame : public CFrameWnd

{

 

protected: // create from serialization only

 CMainFrame();

 DECLARE_DYNCREATE(CMainFrame)


// Attributes

public:

 CExtControlBar m_wndResizableBarGrid;   //PROF-UIS Objects

 CExtWRB < CGridDlg > m_wndResizableDlgGrid;


 

// Operations

public:


// Overrides

public:

 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);


// Implementation

public:

 virtual ~CMainFrame();

#ifdef _DEBUG

 virtual void AssertValid() const;

 virtual void Dump(CDumpContext& dc) const;

#endif


protected:  // control bar embedded members


// Generated message map functions

protected:

 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

 DECLARE_MESSAGE_MAP()

 afx_msg void OnUpdateControlBarMenu(CCmdUI* pCmdUI);

 afx_msg BOOL OnBarCheck(UINT nID);

};


--------------------------------------------------------------------------------------------------


<part of File MainFrm.cpp>


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

 if( !m_wndResizableBarGrid.Create(

   _T("Table Data"),

   this,

   ID_VIEW_PRODGRID,

   WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_GRIPPER

    |CBRS_TOOLTIPS

    |CBRS_FLYBY

    |CBRS_SIZE_DYNAMIC

    |CBRS_HIDE_INPLACE )

   

  )

 {

  TRACE0("Failed to create m_wndResizableBarGrid\n");

  return -1;  // fail to create

 }


 if( !m_wndResizableDlgGrid.Create(IDD_RESIZABLE_GRID_DIALOG, &m_wndResizableBarGrid) )

 {

  TRACE0("Failed to create m_wndResizableBarDlg\n");

  return -1;  // fail to create

 }


 m_wndResizableDlgGrid.ShowSizeGrip( FALSE );

 

 m_wndResizableBarGrid.EnableDocking( CBRS_ALIGN_ANY );

 

 if( !CExtControlBar::FrameEnableDocking(this) )

 {

  ASSERT( FALSE );

  return -1;

 }


 m_wndResizableBarGrid.DockControlBar( AFX_IDW_DOCKBAR_BOTTOM, 1, this );


 return 0;

}

--------------------------------------------------------------------------------------------------

Nicholas Vezirgiannis Jan 27, 2009 - 4:23 AM

In the same code as above, I want to show and hide the grid by showing or hiding the entire Resizable Dialog Control Bar as follows:



m_wndResizableBarGrid.ShowWindow(SW_SHOW);   //or SW_HIDE


RecalcLayout();


This works just fine, but if the user decides to close the Control Bar by clicking on the X on the top right corner and the Control bar is not docked somewhere, the command above will not show it ever again. I have to close and reopen my application for it to function again.


Any ideas.


Thanks in advance.


Technical Support Jan 27, 2009 - 11:37 AM

You should never invoke the ShowWindow() method of any control bar. Please invoke the CFrameWnd::ShowControlBar() method instead.

Nicholas Vezirgiannis Jan 28, 2009 - 1:44 AM

Thanks again that worked fine.

Technical Support Dec 24, 2008 - 1:34 PM

Please remove the CExtWFF template class from your grid window class declaration. The CExtGridWnd class is a flicker free control (written from scratch) which does not need the CExtWFF template. We send you e-mail. If you didn’t receive it, then you can simply write us e-mail to the support mail box at this web site.

Nicholas Vezirgiannis Jan 5, 2009 - 1:48 AM

Thanks. That worked just fine.