?? thresholddlg.cpp
字號:
// ThresholdDlg.cpp : 實現文件
//
#include "stdafx.h"
#include "photoshow.h"
#include "ThresholdDlg.h"
#include "GrayOperator.h"
#include "MainFrm.h"
#include "photoshowDoc.h"
#include "photoshowView.h"
// CThresholdDlg 對話框
IMPLEMENT_DYNAMIC(CThresholdDlg, CDialog)
CThresholdDlg::CThresholdDlg(CWnd* pParent /*=NULL*/)
: CDialog(CThresholdDlg::IDD, pParent)
, m_nNum(120)
, m_nPos(0)
{
m_bModify = false;
}
CThresholdDlg::~CThresholdDlg()
{
SAFE_DELETE (dlg);
}
void CThresholdDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SLIDER, m_SliderNum);
DDX_Text(pDX, IDC_NUM, m_nNum);
DDX_Slider(pDX, IDC_SLIDER, m_nPos);
}
BEGIN_MESSAGE_MAP(CThresholdDlg, CDialog)
ON_EN_CHANGE(IDC_NUM, &CThresholdDlg::OnEnChangeNum)
ON_BN_CLICKED(IDC_SAVE, &CThresholdDlg::OnBnClickedSave)
ON_WM_HSCROLL()
ON_BN_CLICKED(IDCANCEL, &CThresholdDlg::OnBnClickedCancel)
END_MESSAGE_MAP()
// CThresholdDlg 消息處理程序
void CThresholdDlg::Refresh(void)
{
UpdateData(TRUE);
CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
CphotoshowView* pView = (CphotoshowView*)pMain->GetActiveView();
ThresholdTrans(pView->m_pImageBuffer, pView->m_pImageTempBuffer,
pView->m_nPicWidth, pView->m_nPicHeight, m_nNum);
dlg->Refresh();
}
BOOL CThresholdDlg::OnInitDialog()
{
CDialog::OnInitDialog();
dlg = new CPreviewDlg(this);
dlg->m_nType = 1;
dlg->m_bEnableClose = false;
dlg->Create(IDD_PREVIEW);
dlg->ShowWindow(SW_SHOW);
m_SliderNum.SetRange(0, 255);
m_nPos = 120;
UpdateData(FALSE);
Refresh();
return TRUE; // return TRUE unless you set the focus to a control
// 異常: OCX 屬性頁應返回 FALSE
}
void CThresholdDlg::OnEnChangeNum()
{
UpdateData(TRUE);
if (m_nNum < 0)
m_nNum = 0;
else if (m_nNum > 255)
m_nNum = 255;
m_nPos = m_nNum;
UpdateData(FALSE);
Refresh();
m_bModify = true;
}
void CThresholdDlg::OnBnClickedSave()
{
CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
CphotoshowView* pView = (CphotoshowView*)pMain->GetActiveView();
pView->OnFileSave();
m_bModify = false;
}
void CThresholdDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
UpdateData(TRUE);
m_nNum = m_nPos;
UpdateData(FALSE);
Refresh();
m_bModify = true;
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CThresholdDlg::OnBnClickedCancel()
{
if (m_bModify)
{
if (IDYES == MessageBox(L"圖像已經更改,是否保存?", L"photoshow", MB_YESNO))
OnBnClickedSave();
}
OnCancel();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -