主题

1.
滑块控件属性设置

2.
使用滑块控件设置颜色

3.
显示Slider的数值

4.

5.

    

属性

滑块控件属性设置

//代码设置属性

    

代码::

/////////////////////////////////////////////////////////////////////////////
// CProject02Dlg dialog
//class CProject02Dlg : public CDialog
//{
// Construction
//public:
//    CProject02Dlg(CWnd* pParent = NULL);    // standard constructor
    COLORREF m_clColor;

// Dialog Data

在CProject02Dlg中右键添加个Add MemberFunction

void CProject02Dlg::updatePicCtrl()
{
    CDC * pDC = m_ctrl_pic1.GetDC();
    CRect rc;
    m_ctrl_pic1.GetClientRect(rc);
    pDC -> FillRect(rc, & CBrush(m_clColor));
    m_ctrl_pic1.ReleaseDC(pDC);

}

 
在BOOL
CProject02Dlg::OnInitDialog()
部分添加slider的初始化部分代码
    // TODO: Add extra initialization
here
    m_ctrl_Slider1_Red.SetRange(0,255,FALSE);
    m_ctrl_Slider2_Green.SetRange(0,255,FALSE);

m_ctrl_Slider3_Blue.SetRange(0,255,FALSE);

 
 
void CProject02Dlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*
pScrollBar)
{

    // TODO: Add your message handler code here and/or
call default
    if (nSBCode == SB_THUMBTRACK)
    {
        if
(pScrollBar -> m_hWnd == m_ctrl_Slider1_Red.m_hWnd)
        {
            m_nEdt1_Red = nPos;
            UpdateData(FALSE);
        }
        
        if
(pScrollBar -> m_hWnd == m_ctrl_Slider2_Green.m_hWnd)
        {
            m_nEdt2_Green = nPos;
            UpdateData(FALSE);
        }
        
        if
(pScrollBar -> m_hWnd == m_ctrl_Slider3_Blue.m_hWnd)
        {
            m_nEdt3_Blue = nPos;
            UpdateData(FALSE);
        }
        
        m_clColor = RGB(m_nEdt1_Red,m_nEdt2_Green,m_nEdt3_Blue);
        updatePicCtrl();
    }

CDialog::OnHScroll(nSBCode, nPos, pScrollBar); }

 
//为每个Edit添加个EN_Change消息
void CProject02Dlg::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.
    
    // TODO: Add your control notification handler code
here
    UpdateData(TRUE);
    m_ctrl_Slider1_Red.SetPos(m_nEdt1_Red);
    updatePicCtrl();    
}
void CProject02Dlg::OnChangeEdit2()
{
    // 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.
    
    // TODO: Add your control notification handler code
here
    UpdateData(TRUE);
    m_ctrl_Slider2_Green.SetPos(m_nEdt2_Green);
    updatePicCtrl();    
}
 
void CProject02Dlg::OnChangeEdit3()
{
    // 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.
    
    // TODO: Add your control notification handler code
here
    UpdateData(TRUE);
    m_ctrl_Slider3_Blue.SetPos(m_nEdt3_Blue);
    updatePicCtrl();
    

}

    

效果图:

 
 
 

附件列表

C++ Code_Slider的更多相关文章

随机推荐

  1. SoapUI中Groovy的实用方法

    1.依照上次结果判断下步是否执行: import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus myTestStep ...

  2. 序列for循环语句

    序列for循环语句 序列for循环语句允许重复遍历一组序列,而这组序列可以是任何可以重复遍历的序列,如由begin()和end()函数定义的STL序列.所有的标准容器都可用作这种序列,同时它也同样可以 ...

  3. 高效使用STL

    高效使用STL  参考:http://blog.jobbole.com/99115/ 仅仅是个选择的问题,都是STL,可能写出来的效率相差几倍:熟悉以下条款,高效的使用STL: 当对象很大时,建立指针 ...

  4. SAS、R以及SPSS的比较__统计语言大战

  5. Web服务器与Servlet容器

    今日要闻: Oracle启动了JRE7到JRE8的自动更新, JRE8发布于2014.3,于2014.10成为java.com默认版本, JRE7发布于2011.7, Oracle指定的Java生命政 ...

  6. Hadoop概念学习系列之常见的分布式文件系统(二十六)

    常见的分布式文件系统有,GFS.HDFS.Lustre .Ceph .GridFS .mogileFS.TFS.FastDFS等.各自适用于不同的领域.它们都不是系统级的分布式文件系统,而是应用级的分 ...

  7. Docker 入门教程(转)

    add by zhj: 可以简单的认为docker是对LXC(Linux Container)封装,它提供一种比LXC高级的API.Docker使用Go语言开发,利用了Linux提供的LXC,AUFS ...

  8. 记拿到鹅厂前端开发暑期实习offer的经历

    #想起来时的路 在真正拿到腾讯实习offer之前,也是看过不少人的面经,心生向往.很早在入前端坑之前,我就想着大四的时候有机会要尝试去腾讯里实习. 大一入门语言就是C++,这让我很无奈,所以我很快的就 ...

  9. [原创]Devexpress XtraReports 系列 3 创建主从报表

    昨天写了系列的第二篇Devexpress XtraReports 系列 2 创建表格报表 . 今天我们来继续系列 3 创建主从报表 首先我们来看看最后实现的效果.Demo最后附上. 开始吧. 第一步, ...

  10. HTML结构标签介绍

    HTML:超文本标记语言   介绍HTML基本标记   1:头部标记(head)-----  头部的内容不会再页面上显示 在头部元素中,一般需要包括标题<title>,基本信息(文档样式, ...