creating a floating scroll bar

Login to reply to this topic.
Tue, 2008-06-17 18:07
Joined: 2007-07-13
Forum posts: 9

I'm trying to create a floating scroll bar, so that all that is seen of the scroll bar frame is the part with the bar. I have it working, except I am unable to update the thumb position. The following code is called every time the scroll bar needs to update. If I change the following code to create a new CEikScrollBarFrame every time the thumb will move. I also tried using MoveVertThumbTo instead of resetting the model every time, and that gave me a wserv 10 panic. Any ideas?

void CFloatingScrollbarFrame::Show(
        const int x,
        const int y,
        const int height,
        const int thumbPosition,
        const int maxScroll,
        const int pageHeight )
{
        if ( 0 == m_pScrollFrame )
        {
                CreateWindowL();
       
                m_pScrollFrame = new CEikScrollBarFrame( this, NULL );
                if( 0 == m_pScrollFrame )
                {
                        return;
                }
                m_pScrollFrame->CreateDoubleSpanScrollBarsL( ETrue, EFalse);
                m_pScrollFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
                m_pScrollFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn );
        }
       
        CHomescreenAppUi *appUI = (CHomescreenAppUi*)CEikonEnv::Static()->EikAppUi();
        appUI->ClientRect();
        TRect clientRect( appUI->ClientRect() );
               
        // set size and position
        TRect frameRect;
        frameRect.SetRect( clientRect.iTl.iX + x, clientRect.iTl.iY + y,
                        clientRect.iBr.iX, clientRect.iTl.iY + y + height );
       
        SetRect( frameRect );
        SetFocus( ETrue );
        ActivateL();
               
        TEikScrollBarModel model;
        model.iThumbSpan = pageHeight;
        model.iThumbPosition = thumbPosition;
        model.iScrollSpan =        maxScroll + pageHeight;
       
        TEikScrollBarFrameLayout layout;
        layout.iTilingMode=TEikScrollBarFrameLayout::EInclusiveRectConstant;
       
        TRect scrollbarRect;
        scrollbarRect.SetRect( 0, 0, clientRect.iBr.iX - x, height );
       
        m_pScrollFrame->TileL( &model, &model, frameRect, scrollbarRect, layout );
}

  • Login to reply to this topic.