User talk:Beover1984

From Nokia Developer Wiki
Jump to: navigation, search

Series 60 3rd---调整list box位置和大小后造成与scroll bar不一致的解决办法

S60 2nd FP3以后标准控件中的scroll bar不再是屏幕下方的两个三角形了,而换成了类似Windows中scroll bar的样式,这种样式更直观,用户感觉确实更好.然而在移植一个项目到S60 3rd上时碰到了这个问题:调整list box位置和大小后造成与scroll bar不一致.比如:通过对list box调用SetExtent()使其不占满客户区,这时scroll bar的大小并没有改变,造成了list box与scroll bar的错位. 解决办法: 首先通过list box基类CEikListBox::ScrollBarFrame()得到滚动条框架对象CEikScrollBarFrame类型的指针,然后通过CEikScrollBarFrame::GetScrollBarHandle()得到某个滚动条对象CEikScrollBar类型的指针,最后通过CEikScrollBar::SetExtent()调整滚动条的位置就可以了.

//Set the position of listbox
void CXXXContainer::SetListboxPos( const TPoint aPoint )
iListPos = aPoint;
if( iListBox )
TRect rect = Rect();
TSize size( Rect().Width(), Rect().iBr.iY - iListPos.iY );
iListBox->SetExtent( iListPos, size );
CEikScrollBar *scrollBar = iListBox->ScrollBarFrame()->GetScrollBarHandle( CEikScrollBar::EVertical );
if( scrollBar )
TPoint pos = scrollBar->Position();
pos.iY = iListPos.iY;
scrollBar->SetExtent( pos, scrollBar->MinimumSize() );
This page was last modified on 26 July 2011, at 02:23.
95 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.