主题

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. MySQL修改root密码的几种方法

    方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password('新密码'); 例子:my ...

  2. Nodejs_day02

    Nodejs的事件模块 var events = require('events'); var eventEmitter = new events.EventEmitter();//创建EventEm ...

  3. 庞锋 OpenCV 视频 学习进度备忘

    书签:另外跳过的内容有待跟进 学习资源: opencv视频教程目录(初级)   主讲:庞锋,毕业于电子科技大学 知识基础支持: 线性代数 应用数学 跳过的内容: 1.第1~6集跳过,简单.(2014- ...

  4. Window Redis分布式部署方案 java

    Redis分布式部署方案 Window 1.    基本介绍 首先redis官方是没有提供window下的版本, 是window配合发布的.因现阶段项目需求,所以研究部署的是window版本的,其实都 ...

  5. macos+apache+php+phpmyadmin 的整合过程梳理

    启动Apache 有两种方法: 打开“系统设置偏好(System Preferences)” -> “共享(Sharing)” -> “Web共享(Web Sharing)”. 打开“终端 ...

  6. other 遮罩层

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  7. 【LoadRunner】安装LoadRunner时提示缺少vc2005_sp1_with_atl_fix_redist解决方案

    我的电脑在安装UFT时,被要求需要卸载本机上安装的LoadRunner11,当LoadRunner11被卸载后,进行重新安装LoadRunner11时,会报缺少vc2005_sp1_with_atl_ ...

  8. 前端异步解决方案——mmDeferred

    Deferred是前端解决异步操作的一种编程范式,后来出现的Promise规范更是让其普适性大大提高.不过Promise规范也存在分岐.现在最流行的是Promise/A规范. Promise/A大致是 ...

  9. STM32中的位带(bit-band)操作

    转:http://blog.csdn.net/gaojinshan/article/details/11479929 //位带操作,实现51类似的GPIO控制功能 //具体实现思想,参考<< ...

  10. Python基础 字符串的魔法

    capitalize(self) 返回值:将字符串的第一个首字母变成大写,其他字母变小写 s = 'hello World' ss = s.capitalize() print(ss) Hello w ...