www.pudn.com > ColorDlg-v1.1.rar > ColorSetDlg.cpp


// ColorSetDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "ColorDlg.h" 
#include "ColorSetDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CColorSetDlg dialog 
 
 
CColorSetDlg::CColorSetDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CColorSetDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CColorSetDlg) 
	m_nB = 0; 
	m_nG = 0; 
	m_nR = 0; 
	//}}AFX_DATA_INIT 
} 
 
 
void CColorSetDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CColorSetDlg) 
	DDX_Control(pDX, IDC_STATIC_B, m_strB); 
	DDX_Control(pDX, IDC_STATIC_G, m_strG); 
	DDX_Control(pDX, IDC_SLIDER_B, m_sB); 
	DDX_Control(pDX, IDC_STATIC_R, m_strR); 
	DDX_Control(pDX, IDC_SLIDER_G, m_sG); 
	DDX_Control(pDX, IDC_SLIDER_R, m_sR); 
	DDX_Text(pDX, IDC_B, m_nB); 
	DDV_MinMaxInt(pDX, m_nB, 0, 255); 
	DDX_Text(pDX, IDC_G, m_nG); 
	DDV_MinMaxInt(pDX, m_nG, 0, 255); 
	DDX_Text(pDX, IDC_R, m_nR); 
	DDV_MinMaxInt(pDX, m_nR, 0, 255); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CColorSetDlg, CDialog) 
	//{{AFX_MSG_MAP(CColorSetDlg) 
	ON_WM_CANCELMODE() 
	ON_WM_HSCROLL() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CColorSetDlg message handlers 
 
BOOL CColorSetDlg::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
//	m_nR=m_nG=m_nB=0; 
	UpdateData(FALSE); 
 
 
	m_sR.SetRange(0,255);	m_sR.SetPos(m_nR); 
	m_sG.SetRange(0,255);	m_sG.SetPos(m_nG); 
	m_sB.SetRange(0,255);	m_sB.SetPos(m_nB); 
 
	CString strR; 
	strR.Format("%d",m_sR.GetPos()); 
	m_nR=m_sR.GetPos(); 
	m_strR.SetWindowText(strR); 
	 
 
	CString strG; 
	strG.Format("%d",m_sG.GetPos()); 
	m_nG=m_sG.GetPos(); 
	m_strG.SetWindowText(strG); 
	 
 
	CString strB; 
	strB.Format("%d",m_sB.GetPos()); 
	m_nB=m_sB.GetPos(); 
	m_strB.SetWindowText(strB); 
	 
 
 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CColorSetDlg::OnCancelMode()  
{ 
	CDialog::OnCancelMode(); 
	 
	// TODO: Add your message handler code here 
	 
} 
 
//DEL void CColorSetDlg::OnReleasedcaptureSliderR(NMHDR* pNMHDR, LRESULT* pResult)  
//DEL { 
//DEL 	// TODO: Add your control notification handler code here 
//DEL 	CString InfoR; 
//DEL 	InfoR.Format("%d",m_sR.GetPos()); 
//DEL //	n1=m_sR.GetPos(); 
//DEL //	m_nR=m_sR.GetPos(); 
//DEL //	m_strR.SetWindowText(Info); 
//DEL 	SetDlgItemText(IDC_STATIC_R,InfoR); 
//DEL 	SetDlgItemText(IDC_R,InfoR); 
//DEL 	 
//DEL 	*pResult = 0; 
//DEL } 
 
//DEL void CColorSetDlg::OnReleasedcaptureSliderG(NMHDR* pNMHDR, LRESULT* pResult)  
//DEL { 
//DEL 	// TODO: Add your control notification handler code here 
//DEL 	CString InfoG; 
//DEL 	InfoG.Format("%d",m_sG.GetPos()); 
//DEL //	n2=m_sG.GetPos(); 
//DEL //	m_nG=m_sG.GetPos(); 
//DEL //	m_strG.SetWindowText(Info); 
//DEL 	SetDlgItemText(IDC_STATIC_G,InfoG); 
//DEL 	SetDlgItemText(IDC_G,InfoG); 
//DEL 	 
//DEL 	*pResult = 0; 
//DEL } 
 
//DEL void CColorSetDlg::OnReleasedcaptureSliderB(NMHDR* pNMHDR, LRESULT* pResult)  
//DEL { 
//DEL 	// TODO: Add your control notification handler code here 
//DEL 	CString InfoB; 
//DEL 	InfoB.Format("%d",m_sB.GetPos()); 
//DEL //	n3=m_sB.GetPos(); 
//DEL //	m_nB=m_sB.GetPos(); 
//DEL //	m_strB.SetWindowText(Info); 
//DEL 	SetDlgItemText(IDC_STATIC_B,InfoB); 
//DEL 	SetDlgItemText(IDC_B,InfoB); 
//DEL 	 
//DEL 	*pResult = 0; 
//DEL } 
 
void CColorSetDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)  
{ 
	// TODO: Add your message handler code here and/or call default 
	CSliderCtrl* pSlide = (CSliderCtrl*) pScrollBar; 
    CString strText; 
 
    // Two trackbars are sending 
    //  HSCROLL messages (different processing) 
    switch(pScrollBar->GetDlgCtrlID()) { 
    case IDC_SLIDER_R:  
        strText.Format("%d", pSlide->GetPos()); 
        SetDlgItemText(IDC_STATIC_R, strText); 
		SetDlgItemText(IDC_R,strText); 
        break; 
    case IDC_SLIDER_G: 
        strText.Format("%d", pSlide->GetPos()); 
        SetDlgItemText(IDC_STATIC_G, strText); 
		SetDlgItemText(IDC_G,strText); 
        break; 
	case IDC_SLIDER_B: 
        strText.Format("%d", pSlide->GetPos()); 
        SetDlgItemText(IDC_STATIC_B, strText); 
		SetDlgItemText(IDC_B,strText); 
        break; 
    }  
 
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar); 
}