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 row, column header painting Collapse All
Subject Author Date
Torsten Schucht Jun 14, 2007 - 9:42 AM

Dear Support Team,

I am using CExtGridWnd. I am searching for a way to apply the painting of the active theme to the row and column header of the CExtGridWnd (like the headers in the CExtReportGrid). They are always painted old style grey.

Thanks.

Torsten Schucht Jun 15, 2007 - 9:10 AM

Thanks, that works fine.

Now I have another question: how to get the scrollbar in the CExtGridWnd painted in the color scheme of the PaintManager (as it is done in the example SimpleGrids) ?

Technical Support Jun 15, 2007 - 10:48 AM

By default, the grid control uses built-in window scroll bars which are implemented as part of the non-client area. You can use CScrollBar scroll bar common controls or CExtScrollBar Prof-UIS scroll bars in it instead. The latter scroll bars are what you are looking for. The easiest way to embed Prof-UIS scroll bars into the grid control is to use the following template class:

template < class _BT >
class CExtNicerScrollBars : public _BT
{
public:
      mutable CExtScrollBar m_wndScrollBarH, m_wndScrollBarV;
protected:
      bool _EnsureScrollBarsCreated() const
      {
            if(         m_wndScrollBarH.GetSafeHwnd() != NULL
                  &&    m_wndScrollBarV.GetSafeHwnd() != NULL
                  )
                  return true;
            m_wndScrollBarH.m_eSO = CExtScrollBar::__ESO_BOTTOM;
            m_wndScrollBarV.m_eSO = CExtScrollBar::__ESO_RIGHT;
            if( m_wndScrollBarV.GetSafeHwnd() == NULL )
            {
                  if( ! m_wndScrollBarV.Create(
                              WS_CHILD|WS_VISIBLE|SBS_VERT|SBS_RIGHTALIGN,
                              CRect(0,0,0,0),
                              ((CWnd*)this),
                              1
                              )
                        )
                  {
                        ASSERT( FALSE );
                        return false;
                  }
            }
            if( m_wndScrollBarH.GetSafeHwnd() == NULL )
            {
                  if( ! m_wndScrollBarH.Create(
                              WS_CHILD|WS_VISIBLE|SBS_HORZ|SBS_BOTTOMALIGN,
                              CRect(0,0,0,0),
                              ((CWnd*)this),
                              2
                              )
                        )
                  {
                        ASSERT( FALSE );
                        return false;
                  }
            }
            m_wndScrollBarH.SyncReservedSpace( &m_wndScrollBarV );
            m_wndScrollBarV.SyncReservedSpace( &m_wndScrollBarH );
            return true;
      }
public:
      virtual CScrollBar* GetScrollBarCtrl(int nBar) const
      {
            ASSERT_VALID( this );
            switch( nBar )
            {
            case SB_HORZ:
            case SB_VERT:
                  if( _EnsureScrollBarsCreated() )
                  {
                        CExtScrollBar * pScrollBar = ( nBar == SB_HORZ ) ? (&m_wndScrollBarH) : (&m_wndScrollBarV);
                        ASSERT_VALID( pScrollBar );
                        ASSERT( pScrollBar->GetSafeHwnd() != NULL );
                        return pScrollBar;
                  }
            break;
            }
            return NULL;
      }
};
You should simply use the CExtNicerScrollBars < CExtGridWnd > template based type instead of the CExtGridWnd class type. You can also use the CExtNicerScrollBars template class in the CExtTreeGridWnd tree grid.

Technical Support Jun 14, 2007 - 12:23 PM

You should apply the __EGWS_EX_PM_COLORS grid style in this way:

 m_wndGrid.SiwModifyStyleEx( __EGWS_EX_PM_COLORS );
If it is applied, the grid window is painted using the Paint Manager’s color scheme, the default system colors otherwise.