📄 thresholddlg.cpp
字号:
// ThresholdDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ViewDIB.h"
#include "ThresholdDlg.h"
#include "ViewDIBDoc.h"
#include "ViewDIBView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CThresholdDlg dialog
CThresholdDlg::CThresholdDlg(CWnd* pParent /*=NULL*/)
: CDialog(CThresholdDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CThresholdDlg)
m_Value = 0;
//}}AFX_DATA_INIT
}
void CThresholdDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CThresholdDlg)
DDX_Text(pDX, IDC_EDIT1, m_Value);
DDV_MinMaxLong(pDX, m_Value, 0, 255);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CThresholdDlg, CDialog)
//{{AFX_MSG_MAP(CThresholdDlg)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BUTTON_OK, OnButtonOk)
ON_BN_CLICKED(ID_FINISH, OnFinish)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CThresholdDlg message handlers
BOOL CThresholdDlg::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE;
}
void CThresholdDlg::OnPaint()
{
CPaintDC dc(this);
UpdateData(TRUE);
//some prepare work for painting.
CWnd* pWnd = GetDlgItem(IDC_G);
CDC* pControlDC = pWnd->GetDC();
pWnd->Invalidate();
pWnd->UpdateWindow();
CPen penD;
CBrush brush;
CPen* pOldPen;
CBrush* pOldBrush;
penD.CreatePen(PS_SOLID, 2, RGB(0,0,0));
brush.CreateSolidBrush(RGB(192, 192, 192));
pOldBrush = pControlDC->SelectObject(&brush);
pOldPen = pControlDC->SelectObject(&penD);
//drow the histogram and color bar.
pControlDC->Rectangle(0, 0, 258, 110);
pControlDC->SelectObject(pOldBrush);
for(int i=0;i<256;i++)
{
pOldPen = pControlDC->SelectObject(&penD);
pControlDC->MoveTo(i+1, 110);
pControlDC->LineTo(i+1, 110-m_L[i]);
pControlDC->SelectObject(pOldPen);
}
//do the end work for paint.
pWnd->ReleaseDC(pControlDC);
UpdateData(FALSE);
}
void CThresholdDlg::OnButtonOk()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CMainFrame* pCMainWnd = (CMainFrame*)GetParent();
pCMainWnd->m_value = m_Value;
pCMainWnd->OnBinary();
UpdateData(FALSE);
return;
}
void CThresholdDlg::OnFinish()
{
// TODO: Add your control notification handler code here
OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -