BRIGHTNESS.CPP
上传用户:alisonmail
上传日期:2013-02-28
资源大小:500k
文件大小:3k
- // Brightness.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ImageView.h"
- #include "Brightness.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CBrightness dialog
- CBrightness::CBrightness(CWnd* pParent /*=NULL*/)
- : CDialog(CBrightness::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CBrightness)
- //}}AFX_DATA_INIT
- m_nBrightness = 101;
- strcpy( m_szTitle, "Set Brightness" );
- strcpy( m_szLabel, "Brightness" );
- }
- void CBrightness::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CBrightness)
- DDX_Control(pDX, IDC_SCROLLBAR1, m_BrightnessScroll);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CBrightness, CDialog)
- //{{AFX_MSG_MAP(CBrightness)
- ON_WM_VSCROLL()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CBrightness message handlers
- BOOL CBrightness::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- CenterWindow();
- m_BrightnessScroll.SetScrollRange( 1, 200, FALSE );
- m_BrightnessScroll.SetScrollPos( 100, FALSE );
- UpdateBrightness();
- SetWindowText( m_szTitle );
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CBrightness::OnOK()
- {
- m_nBrightness = 201 - m_BrightnessScroll.GetScrollPos();
-
- CDialog::OnOK();
- }
- void CBrightness::UpdateBrightness( void )
- {
- char jnk[100];
-
- wsprintf( jnk, "%s:%d", m_szLabel, 201 - m_nBrightness );
- SetDlgItemText( IDC_BRIGHTNESSVALUE, jnk );
-
- }
- void CBrightness::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
- {
- switch( nSBCode ){
- case SB_THUMBPOSITION:
- m_nBrightness = nPos;
- m_BrightnessScroll.SetScrollPos( m_nBrightness, TRUE );
- UpdateBrightness();
- break;
- case SB_LINEDOWN:
- if( m_nBrightness < 200 ) m_nBrightness++, m_BrightnessScroll.SetScrollPos( m_nBrightness, TRUE );
- UpdateBrightness();
- break;
- case SB_LINEUP:
- if( m_nBrightness > 0 ) m_nBrightness--, m_BrightnessScroll.SetScrollPos( m_nBrightness, TRUE );
- UpdateBrightness();
- break;
- case SB_PAGEUP:
- if( m_nBrightness > 0 ){
- m_nBrightness -= 10;
- if( m_nBrightness < 0 ) m_nBrightness = 0;
- m_BrightnessScroll.SetScrollPos( m_nBrightness, TRUE );
- }
- UpdateBrightness();
- break;
- case SB_PAGEDOWN:
- if( m_nBrightness < 200 ){
- m_nBrightness += 10;
- if( m_nBrightness > 200 ) m_nBrightness = 200;
- m_BrightnessScroll.SetScrollPos( m_nBrightness, TRUE );
- }
- UpdateBrightness();
- break;
- }
-
- CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
- }