×
Namespaces

Variants
Actions

监听滚动条事件通知

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
User:Jiangbaolan 在 01 Apr 2009 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

详细描述 该代码片段演示了如何监听滚动条事件。注意:代码中的MEikScrollBarObserver::HandleScrollEventL()使用需要触摸UI支持。该代码可以通过自签名执行。

MMP文件 需要下列链接库

Code: LIBRARY eikcoctl.lib头文件

Code:

  1. include <coecntrl.h> // CCoeControl
  2. include <eiksbobs.h> // MEikScrollBarObserver

class CMyContainer : public CCoeControl, public MEikScrollBarObserver

   {
   // ...
   
   private:  // Functions from base classes
       /**
        * From MEikScrollBarObserver.
        */
       void HandleScrollEventL(CEikScrollBar* aScrollBar,
               TEikScrollEvent aEventType);
   };

源文件

Code:

  1. include <eiksbfrm.h> // CEikScrollBarFrame/**
* From MEikScrollBarObserver.
*/

void CMyContainer::HandleScrollEventL(CEikScrollBar* aScrollBar,

       TEikScrollEvent aEventType)
   {
   if (!aScrollBar)
       {
       return;
       }
   
   switch (aEventType)
       {
       case EEikScrollLeft:
           {
           // Moving left one step
           break;
           }
       case EEikScrollRight:
           {
           // Moving right one step
           break;
           }

       case EEikScrollUp:
           {
           // Moving up one step
           break;
           }
       case EEikScrollDown:
           {
           // Moving down one step
           break;

case EEikScrollPageLeft:

           {
           // Moving left one page
           break;
           }
       case EEikScrollPageRight:
           {
           // Moving right one page
           break;
           }

       case EEikScrollPageUp:
           {
           // Moving up one page
           break;
           }
       case EEikScrollPageDown:
           {
           // Moving down one page
           break;
           }

       case EEikScrollThumbDragHoriz:
           {
           // Horizontal drag started
           break;
           }
       case EEikScrollThumbReleaseHoriz:
           {
           // Horizontal drag released
           break;
           }

       case EEikScrollThumbDragVert:
           {
           // Vertical drag started
           break;
           }
       case EEikScrollThumbReleaseVert:
           {
           // Vertical drag released
           break;
           }

       case EEikScrollHome:
           {
           // Scrolled to the beginning (horiz.)
           break;
           }
       case EEikScrollEnd:
           {
           // Scrolled to the end (horiz.)
           break;
           }

       case EEikScrollTop:
           {
           // Scrolled to the top (vert.)
           break;
           }
       case EEikScrollBottom:
           {
           // Scrolled to the bottom (vert.)
           break;
           }
           
       default:
           {
           break;
           }
       }
   }
This page was last modified on 15 December 2011, at 09:33.
31 page views in the last 30 days.
×