字画卷动类的实现代码

来源:互联网 发布:沈航网络认证客户端 编辑:程序博客网 时间:2024/04/28 04:10
// public API   // create the window; remove WS_VSCROLL to avoid showing scrollbar, remove WS_TABSTOP to disable keyboard scrolling.   BOOL Create(const RECT& rect, CWnd* pParentWnd, UINT uStyle = WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|WS_GROUP, UINT nID = 0);   // activate/deactivate wrapping mode:   void SetWrapping(BOOL bWrap);   // Sets the color used for the background (if no pattern is set) or margins (if pattern is set and not tiled)   void SetBgColor(COLORREF clrBg);   // Sets the color used for text   void SetFgColor(COLORREF clrBg);   // Sets the font; size is in points, see LOGFONT documentation for weight constants   void SetFont(const CString& strName, int nSize, int nWeight);   // Sets the text to be displayed   void SetText(const CString& strText);   // Sets the bitmap to be displayed above the text   CBitmap* SetLogo(CBitmap* pbmpLogo);   // Sets the background pattern   CBitmap* SetPattern(CBitmap* pbmpPattern, BOOL bTile);   // Sets the time between frames (autoscrolling speed) (will revert to default if less than 0) (milliseconds)   void SetScrollDelay(int nScrollDelay);   // Sets the delay when autoscrolling pauses (will disable pausing if set less than scroll delay) (milliseconds)   void SetScrollPause(int nScrollPause);

1.引入工程 CScrollerCtrl 类
2. 

CScrollerCtrl  m_scroller;

3.在OnInitDialog中 

    m_scroller.SetPattern(CBitmap::FromHandle((HBITMAP)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_BITMAP2), IMAGE_BITMAP, 0,0, LR_SHARED)), FALSE); //设置的是背景图案    m_scroller.SetBgColor(RGB(255,255,255)); //设置背景颜色    m_scroller.SetFgColor(RGB(0,127,0)); // 设置前景色     m_scroller.SetLogo(CBitmap::FromHandle((HBITMAP)::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_BITMAP3), IMAGE_BITMAP, 0,0, LR_SHARED)));// 画册logo   // text   CString strIntro;   strIntro.LoadString(IDS_TEST);   m_scroller.SetText(strIntro);   //设置内容   CRect rect;   GetClientRect(&rect);   m_scroller.Create(rect, this);    SetScrollDelay(1000);//设置卷动速度


demo下载 地址:下载地址 

原创粉丝点击