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 General Discussion » theme support for ScrollBar in Dervied CScrollView class. Collapse All
Subject Author Date
Roongrit Charoensupkul Sep 12, 2006 - 9:47 PM

Hi,

I’ve just create a project from ProfUIS Wizard for MDI Application. My View Class is derived from CScrollView. How can I apply theme on scrollbars? I want the scrollbar shown like in your Bitmap Editor example.

Thanks.

Technical Support Sep 13, 2006 - 11:33 AM

First, add CExtScrollBar members to the class declaration:

  ...
    CExtScrollBar m_wndScrollBarH, m_wndScrollBarV;
    ...
Then override the GetScrollBarCtrl virtual method:
   ...
    virtual CScrollBar * GetScrollBarCtrl(int nBar) const;
    ...

    CScrollBar * CAviView::GetScrollBarCtrl(int nBar) const
    {
        ASSERT_VALID( this );
        if( m_hWnd == NULL || (! ::IsWindow(m_hWnd) ) )
            return NULL;
        ASSERT( nBar == SB_HORZ || nBar == SB_VERT );
        if( nBar == SB_HORZ )
        {
            if( m_wndScrollBarH.GetSafeHwnd() != NULL )
                return ( const_cast < CExtScrollBar * > ( &m_wndScrollBarH ) );
        }
        else
        {
            if( m_wndScrollBarV.GetSafeHwnd() != NULL )
                return ( const_cast < CExtScrollBar * > ( &m_wndScrollBarV ) );
        }
        return NULL;
    } 
    ...
The last step is to reate scroll bars in the OnCreate() method
    ...
    int CAviView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {
        if( CBaseView::OnCreate(lpCreateStruct) == -1 )
            return -1;
    
     ////////////////////// 
        m_wndScrollBarH.m_eSO = CExtScrollBar::__ESO_BOTTOM;
        m_wndScrollBarV.m_eSO = CExtScrollBar::__ESO_RIGHT;
        if( ! m_wndScrollBarV.Create(
            WS_CHILD | WS_VISIBLE | SBS_VERT | SBS_RIGHTALIGN,
            CRect(0,0,0,0),
            this,
            1))
        {
            ASSERT( FALSE );
            return -1;
        }
        if( ! m_wndScrollBarH.Create(
            WS_CHILD | WS_VISIBLE | SBS_HORZ | SBS_BOTTOMALIGN,
            CRect(0,0,0,0),
            this,
            2))
        {
            ASSERT( FALSE );
            return -1;
        }
        m_wndScrollBarH.SyncReservedSpace( &m_wndScrollBarV );
        m_wndScrollBarV.SyncReservedSpace( &m_wndScrollBarH );


        ...
    
        return 0;
    }

Suhai Gyorgy Sep 13, 2006 - 2:22 AM

I think what you need to use is CExtScrollWnd instead of CScrollView