symbian 5th系统滚动条使用
貌似好久没有更新自己的博客了。很怀恋这些一直拥护我的博友们。工作的迁移,环境的变化一切都来的是不是有点太突然,但是还好有大伙的陪伴,使我的目标更明确。。。
再次谢谢各位博友了。
过来分享下可可哥的经验。
还是直接上代码吧。
让大家见笑了。争取抽点时间写写我自己的东西。
- class CMyControl: public CCoeControl, public MEikScrollBarObserver {
- public:// Constructors and destructor ~CMyControl();
- static CMyControl* NewL(TRect aRect); static CMyControl* NewLC(TRect aRect);
- private:
- CMyControl(); void ConstructL(TRect aRect);
- void Draw( const TRect& aRect ) const; virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
- TInt CountComponentControls() const; CCoeControl* ComponentControl( TInt aIndex ) const;
- void CreateScrollBar();
- private:///MEikScrollBarObserver void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType );
- protected:
- void SizeChanged();
- private:
- CEikScrollBarFrame* iSBFrame; TInt iScrollSpan;
- TInt iScrollPos; TBool iIsScrollDown;
- };
- // Implementation of scroll bar in custom control along with number of movement by scrollbar in one Drag.
- // ScrollBar in symbian c++ ("Symbian c++").
- void CMyControl::CreateScrollBar() {
- iScrollPos=-1;// initial scroll pos is -1 as 0 specify the first span/drag. iScrollSpan=1;// scrollbar moves by one item at a time
- iSBFrame=new ( ELeave ) CEikScrollBarFrame( this,this); iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn);
- iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse);// create scrollbar iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);//type of scrollbar
- }
- void CMyControl::SizeChanged() {
- // Here you are required to define the size of your scrollbar// TInt listStatusPaneHeight=60;
- TEikScrollBarFrameLayout layout; TEikScrollBarModel myModel;
- TEikScrollBarModel myModel2; myModel.iThumbSpan=1;
- myModel.iScrollSpan =iScrollSpan; layout.iTilingMode=TEikScrollBarFrameLayout::EInclusiveRectConstant;
- TRect fullRect =TRect(TPoint(Rect().iTl.iX,Rect().iTl.iY+listStatusPaneHeight),TSize(Rect().Size().iWidth,Rect ().Size().iHeight-listStatusPaneHeight)); TRect inclRect = fullRect;
- if(iSBFrame) {
- TBool stat = iSBFrame->TileL(&myModel2, &myModel, fullRect, inclRect, layout); iSBFrame->DrawScrollBarsNow();
- } }
- void CMyControl::HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType )
- { switch(aEventType)
- { case EEikScrollThumbDragVert:
- { CEikScrollBar* sb= iSBFrame->VerticalScrollBar();// get an object of your scroll bar
- TInt pos=sb->ThumbPosition();/// it will provide new position of scrollbar if(iScrollPos<pos)
- { iScrollPos=pos;/// moving down number of scroll span
- iIsScrollDown=ETrue; }
- else {
- iScrollPos=pos;/// moving down number of scroll span iIsScrollDown=EFalse;
- } DrawNow();
- break; }
- case EEikScrollThumbReleaseVert: break;
- default: break;
- } }
顶(1)
踩(0)
上一篇:文本输入框字符字数的控制
- 最新评论
