HSIDlg.cpp
上传用户:mjs2008
上传日期:2021-05-16
资源大小:5089k
文件大小:3k
源码类别:

生物技术

开发平台:

Visual C++

  1. // HSIDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Cell.h"
  5. #include "HSIDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. // CHSIDlg dialog
  12. int g_nIntGap;
  13. int g_nSatGap;
  14. int g_nHueGap;
  15. extern CPoint scroll_lefttop;
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CHSIDlg dialog
  18. CHSIDlg::CHSIDlg(CWnd* pParent /*=NULL*/)
  19. : CDialog(CHSIDlg::IDD, pParent)
  20. {
  21. //{{AFX_DATA_INIT(CHSIDlg)
  22. m_bEx = FALSE;
  23. //}}AFX_DATA_INIT
  24. }
  25. CHSIDlg::CHSIDlg(RECT *pSelectedRect, CWnd* pParent)
  26. : CDialog(CHSIDlg::IDD, pParent)
  27. {
  28. //{{AFX_DATA_INIT(CHSIDlg)
  29. m_bEx = FALSE;
  30. //}}AFX_DATA_INIT
  31. memcpy(&SelectedRect,pSelectedRect,sizeof(RECT));
  32. }
  33. void CHSIDlg::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CDialog::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(CHSIDlg)
  37. DDX_Check(pDX, IDC_HSI_EX, m_bEx);
  38. //}}AFX_DATA_MAP
  39. }
  40. BEGIN_MESSAGE_MAP(CHSIDlg, CDialog)
  41. //{{AFX_MSG_MAP(CHSIDlg)
  42. ON_WM_PAINT()
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CHSIDlg message handlers
  47. BOOL CHSIDlg::OnInitDialog() 
  48. {
  49. CDialog::OnInitDialog();
  50. // TODO: Add extra initialization here
  51. SetDlgItemInt(IDC_HSIRANGE_HUE, 5);
  52. SetDlgItemInt(IDC_HSIRANGE_SAT, 8);
  53. SetDlgItemInt(IDC_HSIRANGE_INT, 8);
  54. return TRUE;  // return TRUE unless you set the focus to a control
  55.               // EXCEPTION: OCX Property Pages should return FALSE
  56. }
  57. void CHSIDlg::OnPaint() 
  58. {
  59. CPaintDC dc(this); // device context for painting
  60. int width, height;
  61. width = SelectedRect.right - SelectedRect.left;
  62. height = SelectedRect.bottom - SelectedRect.top;
  63. char title[128];
  64. sprintf(title, "预览 %d * %d", width, height);
  65. SetDlgItemText(IDC_HSIRANGE_PREVIEW, title);
  66. CWnd *Pic;
  67. Pic = GetDlgItem(IDC_HSIRANGE_PIC);
  68. RECT PicRect;
  69. Pic->GetWindowRect(&PicRect);
  70. ScreenToClient(&PicRect);
  71. CDC *pdc = GetDC();
  72. HDC hdc = pdc->m_hDC;
  73. HDC memdc = ::CreateCompatibleDC(hdc);
  74. BITMAP bmp;
  75. CBitmap::FromHandle(g_hBitmap)->GetBitmap(&bmp);
  76. ::SelectObject(memdc, g_hBitmap);
  77. ::StretchBlt
  78. (
  79. hdc,
  80. PicRect.left + 1,
  81. PicRect.top + 1,
  82. PicRect.right - PicRect.left - 2,
  83. PicRect.bottom - PicRect.top - 2,
  84. memdc,
  85. SelectedRect.left+scroll_lefttop.x,
  86. SelectedRect.top+scroll_lefttop.y,
  87. width,
  88. height,
  89. SRCCOPY
  90. );
  91. ReleaseDC(pdc);
  92. ::DeleteDC(memdc);
  93. // Do not call CDialog::OnPaint() for painting messages
  94. }
  95. void CHSIDlg::OnOK() 
  96. {
  97. int Value;
  98. Value = GetDlgItemInt(IDC_HSIRANGE_HUE);
  99. if(Value < 0 || Value > 100)
  100. {
  101. MessageBox("HUE误差范围不正确。请重新输入!");
  102. GetDlgItem(IDC_HSIRANGE_HUE)->SetFocus();
  103. return;
  104. }
  105. else
  106. g_nHueGap = Value;
  107. Value = GetDlgItemInt(IDC_HSIRANGE_SAT);
  108. if(Value < 0 || Value > 100)
  109. {
  110. MessageBox("SAT误差范围不正确。请重新输入!");
  111. GetDlgItem(IDC_HSIRANGE_SAT)->SetFocus();
  112. return;
  113. }
  114. else
  115. g_nSatGap = Value;
  116. Value = GetDlgItemInt(IDC_HSIRANGE_INT);
  117. if(Value < 0 || Value > 100)
  118. {
  119. MessageBox("INT误差范围不正确。请重新输入!");
  120. GetDlgItem(IDC_HSIRANGE_INT)->SetFocus();
  121. return;
  122. }
  123. else
  124. g_nIntGap = Value;
  125. UpdateData(TRUE);
  126. CDialog::OnOK();
  127. }