主题

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. bzoj1193

    #include<cstdio> #include<cstdlib> #include<algorithm> #include<queue> using ...

  2. Window.onLoad 和 DOMContentLoaded事件的先后顺序

    相信写js的,都知道window.onload吧,但是并不是每个人都知道DOMContentLoaded,其实即使你不知道,很有可能你也经常使用了这个东西. 一般情况下,DOMContentLoade ...

  3. CDH4.1基于Quorum-based Journaling的NameNode HA

    几个星期前, Cloudera发布了CDH 4.1最新的更新版本,这是第一个真正意义上的独立高可用性HDFS NameNode的hadoop版本,不依赖于特殊的硬件或外部软件.这篇文章从开发者的角度来 ...

  4. 轻松学习Linux之理解进程的管理与控制

    本文出自 "李晨光原创技术博客" 博客,谢绝转载!

  5. Spark RDD概念学习系列之RDD的缓存(八)

      RDD的缓存 RDD的缓存和RDD的checkpoint的区别 缓存是在计算结束后,直接将计算结果通过用户定义的存储级别(存储级别定义了缓存存储的介质,现在支持内存.本地文件系统和Tachyon) ...

  6. 非官方的iOS设计指南

    非官方的iOS设计指南 有时候为iOS设计app并不是一件简单的事,但是如果你能找到正确的最新的苹果设备信息,并按照正确的方向,那么为iOS设计app或许会变得简单容易些. 关于这些指南 这些指南描述 ...

  7. ms-class的进化

    ms-class是avalon用得最多的几个绑定之一,也正因为如此其功能一直在扩充中.根据时期的不同,分为旧风格与新风格两种. 旧风格是指正在ms-class后面跟着类外,然后在绑定值中添加表达式,即 ...

  8. <一道题>abc+cba=1333,求满足条件的abc的值,隐含条件a!=0,c!=0

    这类东西,无非就是穷举法.见下面代码: #include <stdio.h> #include <stdlib.h> /* *abc + cba = 1333 * *a = ? ...

  9. [原创]Devexpress XtraReports 系列 7 创建Drill-Down(向下钻取)报表

    昨天发表了Devexpress XtraReports系列第六篇[原创]Devexpress XtraReports 系列 6 创建并排报表,今天我们继续. 今天的主题是创建Drill-Down报表. ...

  10. hdu 2084 数塔 (简单dp)

    http://acm.hdu.edu.cn/showproblem.php?pid=2084 数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory L ...