主题

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. 刚刚大学毕业,自己搭网站遇到的问题 一:tomcat中同时部署两个项目的问题

    最近直接把两个项目打成war包在tomcat下发布,出现了很多莫名奇妙的问题,就是不能发布成功,只能有一个项目能成功,在网上查了很多方法,以为是两个项目中jar包出现冲突,也按照网上的方法把两个项目中 ...

  2. Android学习笔记-Dialog详解

    1.对话框的使用 1.1AlertDialog的显示 简单对话框以及监听的设置:重点掌握三个按钮(也就是三上单词): PositiveButton(确认按钮);NeutralButton(忽略按钮) ...

  3. C# 必应代码搜索

    微软宣布推出必应代码搜索服务,暂时只支持 C# 语言,日后将支持更多代码语言. Visual Studio 用户安装必应搜索插件之后可使用该服务来简化编程任务.Visual Studio 与 MSDN ...

  4. 【原创译文】基于Docker和Rancher的超融合容器云架构

    基于Docker和Rancher的超融合容器云架构 ---来自Rancher和Redapt 超融合架构在现代数据中心是一项巨大的变革.Nutanix公司发明了超融合架构理论,自从我听说他们的“iPho ...

  5. poj 3094 Quicksum

    #include <stdio.h> #include <string.h> ]; int main() { ; int i,len; while(gets(word)) { ...

  6. POJ 2395 Out of Hay(MST)

    [题目链接]http://poj.org/problem?id=2395 [解题思路]找最小生成树中权值最大的那条边输出,模板过的,出现了几个问题,开的数据不够大导致运行错误,第一次用模板,理解得不够 ...

  7. [转] 苹果所有常用证书,appID,Provisioning Profiles配置说明及制作图文

    转自holydancer的CSDN专栏,原文地址:http://blog.csdn.net/holydancer/article/details/9219333 首先得描述一下各个证书的定位,作用,这 ...

  8. C# winform只有一个进程

    在做winform程序的时候,有时候需要客户只能起一个进程,不能起多个进程,用如下代码可以实现. internal static class Program { private static Mute ...

  9. Labview中局部变量和全局变量

    局部变量的作用域是整个VI,它用于在单个VI中传输数据: 全局变量的作用域是整台计算机,它主要用于多个VI之间共享数据

  10. Deep Learning 学习笔记——第9章

    总览: 本章所讲的知识点包括>>>> 1.描述卷积操作 2.解释使用卷积的原因 3.描述pooling操作 4.卷积在实践应用中的变化形式 5.卷积如何适应输入数据 6.CNN ...