www.pudn.com > WhiteBalance.rar > Custom.cpp
// Custom.cpp : implementation file
//
#include "stdafx.h"
#include "WhiteBalance.h"
#include "Custom.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCustom dialog
CCustom::CCustom(CWhiteBalanceDoc *pDocument,CWnd* pParent /*=NULL*/)
: CDialog(CCustom::IDD, pParent)
{
//{{AFX_DATA_INIT(CCustom)
m_Rvalue = _T("");
m_Gvalue = _T("");
m_Bvalue = _T("");
//}}AFX_DATA_INIT
m_Color=RGB(255,255,255);
pDoc=pDocument;
}
void CCustom::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCustom)
DDX_Control(pDX, IDC_SLIDER6, m_SetBvalue);
DDX_Control(pDX, IDC_SLIDER5, m_SetGvalue);
DDX_Control(pDX, IDC_SLIDER4, m_SetRvalue);
DDX_Text(pDX, IDC_RVALUE, m_Rvalue);
DDX_Text(pDX, IDC_GVALUE, m_Gvalue);
DDX_Text(pDX, IDC_BVALUE, m_Bvalue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCustom, CDialog)
//{{AFX_MSG_MAP(CCustom)
ON_WM_HSCROLL()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCustom message handlers
BOOL CCustom::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_SetRvalue.SetRange(0,255);
m_SetGvalue.SetRange(0,255);
m_SetBvalue.SetRange(0,255);
m_SetRvalue.SetPos(255);
m_SetGvalue.SetPos(255);
m_SetBvalue.SetPos(255);
m_Rvalue="255";
m_Gvalue="255";
m_Bvalue="255";
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCustom::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default
UINT id=pScrollBar->GetDlgCtrlID();
switch(id)
{
case IDC_SLIDER4:
m_Rvalue.Format(">d",m_SetRvalue.GetPos());
break;
case IDC_SLIDER5 :
m_Gvalue.Format(">d",m_SetGvalue.GetPos());
break;
case IDC_SLIDER6 :
m_Bvalue.Format(">d",m_SetBvalue.GetPos());
break;
default:break;
}
m_Color=RGB(m_SetRvalue.GetPos(),m_SetGvalue.GetPos(),m_SetBvalue.GetPos());
CRect rc;
GetClientRect(rc);
rc.SetRect(rc.left+385,rc.top+50,rc.right-15,rc.bottom-40);
InvalidateRect(rc);//ºÜÖØÒª
pDoc->m_ChangeFlag=1;
pDoc->m_Color=m_Color;
UpdateData(FALSE);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CCustom::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CBrush newBrush;
newBrush.CreateSolidBrush(m_Color);
CBrush* pOldBrush;
pOldBrush=dc.SelectObject(&amt;newBrush);
CRect rc;
GetClientRect(rc);
dc.Rectangle(rc.left+385,rc.top+50,rc.right-15,rc.bottom-40);
dc.SelectObject(pOldBrush);
// Do not call CDialog::OnPaint() for painting messages
}