DlgMidFilter.cpp
上传用户:gdjinyi
上传日期:2013-02-01
资源大小:1701k
文件大小:3k
源码类别:

源码/资料

开发平台:

Visual C++

  1. // DlgMidFilter.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ch1_1.h"
  5. #include "DlgMidFilter.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CDlgMidFilter dialog
  13. CDlgMidFilter::CDlgMidFilter(CWnd* pParent /*=NULL*/)
  14. : CDialog(CDlgMidFilter::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CDlgMidFilter)
  17. m_iFilterType = -1;
  18. m_iFilterH = 0;
  19. m_iFilterMX = 0;
  20. m_iFilterMY = 0;
  21. m_iFilterW = 0;
  22. //}}AFX_DATA_INIT
  23. }
  24. void CDlgMidFilter::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CDlgMidFilter)
  28. DDX_Radio(pDX, IDC_RAD1, m_iFilterType);
  29. DDX_Text(pDX, IDC_EDIT_FH, m_iFilterH);
  30. DDV_MinMaxInt(pDX, m_iFilterH, 1, 8);
  31. DDX_Text(pDX, IDC_EDIT_FMX, m_iFilterMX);
  32. DDX_Text(pDX, IDC_EDIT_FMY, m_iFilterMY);
  33. DDX_Text(pDX, IDC_EDIT_FW, m_iFilterW);
  34. DDV_MinMaxInt(pDX, m_iFilterW, 1, 8);
  35. //}}AFX_DATA_MAP
  36. }
  37. BEGIN_MESSAGE_MAP(CDlgMidFilter, CDialog)
  38. //{{AFX_MSG_MAP(CDlgMidFilter)
  39. ON_BN_CLICKED(IDC_RAD1, OnRad1)
  40. ON_BN_CLICKED(IDC_RAD2, OnRad2)
  41. ON_BN_CLICKED(IDC_RAD3, OnRad3)
  42. ON_BN_CLICKED(IDC_RAD4, OnRad4)
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CDlgMidFilter message handlers
  47. void CDlgMidFilter::OnRad1() 
  48. {
  49. // 3×1模板
  50. m_iFilterType = 0;
  51. m_iFilterH = 3;
  52. m_iFilterW = 1;
  53. m_iFilterMX = 0;
  54. m_iFilterMY = 1;
  55. // 设置文本框不可用
  56. (CEdit *) GetDlgItem(IDC_EDIT_FH)->EnableWindow(FALSE);
  57. (CEdit *) GetDlgItem(IDC_EDIT_FW)->EnableWindow(FALSE);
  58. (CEdit *) GetDlgItem(IDC_EDIT_FMX)->EnableWindow(FALSE);
  59. (CEdit *) GetDlgItem(IDC_EDIT_FMY)->EnableWindow(FALSE);
  60. // 更新
  61. UpdateData(FALSE);
  62. }
  63. void CDlgMidFilter::OnRad2() 
  64. {
  65. // 1×3模板
  66. m_iFilterType = 1;
  67. m_iFilterH = 1;
  68. m_iFilterW = 3;
  69. m_iFilterMX = 1;
  70. m_iFilterMY = 0;
  71. // 设置文本框不可用
  72. (CEdit *) GetDlgItem(IDC_EDIT_FH)->EnableWindow(FALSE);
  73. (CEdit *) GetDlgItem(IDC_EDIT_FW)->EnableWindow(FALSE);
  74. (CEdit *) GetDlgItem(IDC_EDIT_FMX)->EnableWindow(FALSE);
  75. (CEdit *) GetDlgItem(IDC_EDIT_FMY)->EnableWindow(FALSE);
  76. // 更新
  77. UpdateData(FALSE);
  78. }
  79. void CDlgMidFilter::OnRad3() 
  80. {
  81. // 3×3模板
  82. m_iFilterType = 2;
  83. m_iFilterH = 3;
  84. m_iFilterW = 3;
  85. m_iFilterMX = 1;
  86. m_iFilterMY = 1;
  87. // 设置文本框不可用
  88. (CEdit *) GetDlgItem(IDC_EDIT_FH)->EnableWindow(FALSE);
  89. (CEdit *) GetDlgItem(IDC_EDIT_FW)->EnableWindow(FALSE);
  90. (CEdit *) GetDlgItem(IDC_EDIT_FMX)->EnableWindow(FALSE);
  91. (CEdit *) GetDlgItem(IDC_EDIT_FMY)->EnableWindow(FALSE);
  92. // 更新
  93. UpdateData(FALSE);
  94. }
  95. void CDlgMidFilter::OnRad4() 
  96. {
  97. // 自定义模板
  98. (CEdit *) GetDlgItem(IDC_EDIT_FH)->EnableWindow(TRUE);
  99. (CEdit *) GetDlgItem(IDC_EDIT_FW)->EnableWindow(TRUE);
  100. (CEdit *) GetDlgItem(IDC_EDIT_FMX)->EnableWindow(TRUE);
  101. (CEdit *) GetDlgItem(IDC_EDIT_FMY)->EnableWindow(TRUE);
  102. }
  103. void CDlgMidFilter::OnOK() 
  104. {
  105. // 获取用户设置(更新)
  106. UpdateData(TRUE);
  107. // 判断设置是否有效
  108. if ((m_iFilterMX < 0) || (m_iFilterMX > m_iFilterW - 1) ||
  109. (m_iFilterMY < 0) || (m_iFilterMY > m_iFilterH - 1))
  110. {
  111. // 提示用户参数设置错误
  112. MessageBox("参数设置错误!", "系统提示" , MB_ICONINFORMATION | MB_OK);
  113. // 返回
  114. return;
  115. }
  116. // 退出
  117. CDialog::OnOK();
  118. }