字画卷动类的实现代码

// 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下载 地址:下载地址 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值