BRIGHTNESS.CPP
上传用户:alisonmail
上传日期:2013-02-28
资源大小:500k
文件大小:3k
源码类别:

图片显示

开发平台:

Visual C++

  1. // Brightness.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ImageView.h"
  5. #include "Brightness.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CBrightness dialog
  13. CBrightness::CBrightness(CWnd* pParent /*=NULL*/)
  14. : CDialog(CBrightness::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CBrightness)
  17. //}}AFX_DATA_INIT
  18. m_nBrightness = 101;
  19. strcpy( m_szTitle, "Set Brightness" );
  20. strcpy( m_szLabel, "Brightness" );
  21. }
  22. void CBrightness::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CBrightness)
  26. DDX_Control(pDX, IDC_SCROLLBAR1, m_BrightnessScroll);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CBrightness, CDialog)
  30. //{{AFX_MSG_MAP(CBrightness)
  31. ON_WM_VSCROLL()
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CBrightness message handlers
  36. BOOL CBrightness::OnInitDialog() 
  37. {
  38. CDialog::OnInitDialog();
  39. CenterWindow();
  40. m_BrightnessScroll.SetScrollRange( 1, 200, FALSE );
  41. m_BrightnessScroll.SetScrollPos( 100, FALSE );
  42. UpdateBrightness();
  43. SetWindowText( m_szTitle );
  44. return TRUE;  // return TRUE unless you set the focus to a control
  45.               // EXCEPTION: OCX Property Pages should return FALSE
  46. }
  47. void CBrightness::OnOK() 
  48. {
  49. m_nBrightness = 201 - m_BrightnessScroll.GetScrollPos();
  50. CDialog::OnOK();
  51. }
  52. void CBrightness::UpdateBrightness( void )
  53. {
  54. char jnk[100];
  55. wsprintf( jnk, "%s:%d", m_szLabel, 201 - m_nBrightness );
  56. SetDlgItemText( IDC_BRIGHTNESSVALUE, jnk );
  57. }
  58. void CBrightness::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
  59. {
  60. switch( nSBCode ){
  61. case SB_THUMBPOSITION:
  62. m_nBrightness = nPos;
  63. m_BrightnessScroll.SetScrollPos( m_nBrightness, TRUE );
  64. UpdateBrightness();
  65. break;
  66. case SB_LINEDOWN:
  67. if( m_nBrightness < 200 ) m_nBrightness++, m_BrightnessScroll.SetScrollPos( m_nBrightness, TRUE );
  68. UpdateBrightness();
  69. break;
  70. case SB_LINEUP:
  71. if( m_nBrightness > 0 ) m_nBrightness--, m_BrightnessScroll.SetScrollPos( m_nBrightness, TRUE );
  72. UpdateBrightness();
  73. break;
  74. case SB_PAGEUP:
  75. if( m_nBrightness > 0 ){
  76. m_nBrightness -= 10;
  77. if( m_nBrightness < 0 ) m_nBrightness = 0;
  78. m_BrightnessScroll.SetScrollPos( m_nBrightness, TRUE );
  79. }
  80. UpdateBrightness();
  81. break;
  82. case SB_PAGEDOWN:
  83. if( m_nBrightness < 200 ){
  84. m_nBrightness += 10;
  85. if( m_nBrightness > 200 ) m_nBrightness = 200;
  86. m_BrightnessScroll.SetScrollPos( m_nBrightness, TRUE );
  87. }
  88. UpdateBrightness();
  89. break;
  90. }
  91. CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
  92. }