zoukankan      html  css  js  c++  java
  • C++ Code_ScrollBar

    主题

    1.  ScrollBar的使用

    2.  

    3.  

    4.  

    5.  

        

      属性

    HScrollBar

    VScrollBar

    直接拖拽1其中任意空间到对话框上面是,你一拖拽滚动条,它立即回到原始位置

        
        

    代码::

      

    /*

    在控件上面添加1个HScrollBar和1个Edit控件

     

    */

    //初始化部分添加代码

        // TODO: Add extra initialization here
        CScrollBar *pScroll=(CScrollBar*)GetDlgItem(IDC_SCROLLBAR1);
        pScroll->SetScrollRange(0, 100);
        pScroll->SetScrollPos(0);

        SetDlgItemInt(IDC_EDIT1, 0);

     

    //为对话杠添加1个OnHScroll消息,添加如下代码

    void CProject01Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
    {
        // TODO: Add your message handler code here and/or call default
        int iPos=pScrollBar->GetScrollPos();
        switch (nSBCode)
        {
        case SB_LINERIGHT:
                iPos+=1;
                break;
        case SB_LINELEFT:
                iPos-=1;
                break;
        case SB_PAGERIGHT:
                iPos+=10;
                break;
        case SB_PAGELEFT:
                iPos-=10;
                break;
        case SB_THUMBTRACK:
                iPos=nPos;
                break;
        default:
            break;
        }
        if (iPos<0) iPos=0;
        if (iPos>100) iPos=100;
        pScrollBar->SetScrollPos(iPos);
        SetDlgItemInt(IDC_EDIT1, iPos);
        
        CDialog::OnHScroll(nSBCode, nPos, pScrollBar);

    }

     

    //为Edit1添加OnChange消息

    void CProject01Dlg::OnChangeEdit1()
    {
        // TODO: If this is a RICHEDIT control, the control will not
        // send this notification unless you override the CDialog::OnInitDialog()
        // function and call CRichEditCtrl().SetEventMask()
        // with the ENM_CHANGE flag ORed into the mask.
        CString STR;
        GetDlgItemText(IDC_EDIT1, STR);
        STR.TrimLeft();
        STR.TrimRight();
        INT iPos=0;
        if (STR!="-" && STR!="")
        {
            if (!UpdateData())
            {
                return;
            }
            iPos=m_nEdt1;
        }
        CScrollBar *pScroll=(CScrollBar*)GetDlgItem(IDC_SCROLLBAR1);
        pScroll->SetScrollPos(iPos);
        
        // TODO: Add your control notification handler code here
        
    }
     
        

    效果图:

      





    附件列表

    • 相关阅读:
      进程Queue
      进程ID
      多进程
      queue 生产者、清费者
      让静态页面显示用户登录状态
      apache2.2 + tomcat6 整合以及集群配置整理
      linux安装rzsz
      http_load
      用Ant实现Java项目的自动构建和部署
      Openfire:安装指南
    • 原文地址:https://www.cnblogs.com/xe2011/p/3885723.html
    Copyright © 2011-2022 走看看