VideoCtrlDlg.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // VideoCtrlDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "StoneU_HC_CARDOCX.h"
  5. #include "VideoCtrlDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. extern UINT PORT;
  12. #define COLOR_DEFAULT 64 // brightness, contrast, saturation, hue default value(0~128);
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CVideoCtrlDlg dialog
  15. CVideoCtrlDlg::CVideoCtrlDlg(CWnd* pParent /*=NULL*/)
  16. : CDialog(CVideoCtrlDlg::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CVideoCtrlDlg)
  19. // NOTE: the ClassWizard will add member initialization here
  20. //}}AFX_DATA_INIT
  21. m_hIcon = AfxGetApp()->LoadIcon(IDI_VIDEOCTRL);
  22. m_pParent = pParent;
  23. }
  24. void CVideoCtrlDlg::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CVideoCtrlDlg)
  28. DDX_Control(pDX, IDC_VC_SATURATION, m_ctrlVCS);
  29. DDX_Control(pDX, IDC_VC_RESET, m_ctrlVCReset);
  30. DDX_Control(pDX, IDC_VC_HUE, m_ctrlVCH);
  31. DDX_Control(pDX, IDC_VC_CONTRAST, m_ctrlVCC);
  32. DDX_Control(pDX, IDC_VC_BRIGHTNESS, m_ctrlVCB);
  33. DDX_Control(pDX, IDC_SLIDER_HUE, m_SliderH);
  34. DDX_Control(pDX, IDC_SLIDER_SATURATION, m_SliderS);
  35. DDX_Control(pDX, IDC_SLIDER_CONTRAST, m_SliderC);
  36. DDX_Control(pDX, IDC_SLIDER_BRIGHTNESS, m_SliderB);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(CVideoCtrlDlg, CDialog)
  40. //{{AFX_MSG_MAP(CVideoCtrlDlg)
  41. ON_BN_CLICKED(IDC_VC_RESET, OnVcReset)
  42. ON_WM_CLOSE()
  43. ON_WM_VSCROLL()
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CVideoCtrlDlg message handlers
  48. BOOL CVideoCtrlDlg::OnInitDialog()
  49. {
  50. CDialog::OnInitDialog();
  51. // Set the icon for this dialog. The framework does this automatically
  52. // when the application's main window is not a dialog
  53. SetIcon(m_hIcon, TRUE); // Set big icon
  54. SetIcon(m_hIcon, FALSE); // Set small icon
  55. // TODO: Add extra initialization here
  56. // Init color slider
  57. m_SliderB.SetRange(0, 128);
  58. m_SliderC.SetRange(0, 128);
  59. m_SliderS.SetRange(0, 128);
  60. m_SliderH.SetRange(0, 128);
  61. m_SliderB.SetPos(COLOR_DEFAULT);
  62. m_SliderC.SetPos(COLOR_DEFAULT);
  63. m_SliderS.SetPos(COLOR_DEFAULT);
  64. m_SliderH.SetPos(COLOR_DEFAULT);
  65. // Init button
  66. m_ctrlVCB.SetIcon(IDI_BRIGHTNESS);
  67. m_ctrlVCC.SetIcon(IDI_CONTRAST);
  68. m_ctrlVCH.SetIcon(IDI_HUE);
  69. m_ctrlVCS.SetIcon(IDI_SATURATION);
  70. return TRUE; // return TRUE unless you set the focus to a control
  71. // EXCEPTION: OCX Property Pages should return FALSE
  72. }
  73. void CVideoCtrlDlg::OnVcReset()
  74. {
  75. // TODO: Add your control notification handler code here
  76. m_SliderB.SetPos(COLOR_DEFAULT);
  77. m_SliderC.SetPos(COLOR_DEFAULT);
  78. m_SliderS.SetPos(COLOR_DEFAULT);
  79. m_SliderH.SetPos(COLOR_DEFAULT);
  80. NAME(PlayM4_SetColor)(PORT, 0, COLOR_DEFAULT, COLOR_DEFAULT, COLOR_DEFAULT, COLOR_DEFAULT);
  81. }
  82. void CVideoCtrlDlg::OnClose()
  83. {
  84. // TODO: Add your message handler code here and/or call default
  85. if(m_pParent)
  86. m_pParent->PostMessage(WM_VIDEOCTRL_OK, 0, 0);
  87. else
  88. CDialog::OnClose();
  89. }
  90. void CVideoCtrlDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
  91. {
  92. // TODO: Add your message handler code here and/or call default
  93. int nBrightness, nContrast, nSaturation, nHue;
  94. switch(GetWindowLong(pScrollBar->m_hWnd, GWL_ID))
  95. {
  96. case IDC_SLIDER_BRIGHTNESS:
  97. case IDC_SLIDER_CONTRAST:
  98. case IDC_SLIDER_SATURATION:
  99. case IDC_SLIDER_HUE:
  100. nBrightness = m_SliderB.GetPos();
  101. nContrast = m_SliderC.GetPos();
  102. nSaturation = m_SliderS.GetPos();
  103. nHue = m_SliderH.GetPos();
  104. NAME(PlayM4_SetColor)(PORT, 0, nBrightness, nContrast, nSaturation, nHue);
  105. // NAME(PlayM4_GetColor)(PORT, 0, &nBrightness, &nContrast, &nSaturation, &nHue);
  106. // TRACE("Get color(B,C,S,V):%d, %d, %d, %d\n", nBrightness, nContrast, nSaturation, nHue);
  107. break;
  108. default:
  109. break;
  110. }
  111. CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
  112. }