📄 eraseoption.cpp
字号:
// EraseOption.cpp : implementation file
//
#include "stdafx.h"
#include "ChtRecNero.h"
#include "EraseOption.h"
#include "ChtRecNeroDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// EraseOption dialog
extern CChtRecNeroApp theApp;
typedef struct tag_THREADPARA
{
NERO_DEVICEHANDLE Handle;
NEROAPI_CDRW_ERASE_MODE mode;
EraseOption* pThis;
} THREADPARA,*PTHREADPARA;
EraseOption::EraseOption(CWnd* pParent /*=NULL*/)
: CDialog(EraseOption::IDD, pParent)
{
m_time=0;
m_step=0;
m_pos=0;
//{{AFX_DATA_INIT(EraseOption)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void EraseOption::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(EraseOption)
DDX_Control(pDX, IDCANCEL, m_Cancel);
DDX_Control(pDX, IDC_ERASE, m_Erase);
DDX_Control(pDX, IDC_ERASEPROGRESS, m_pgsEraseProgress);
DDX_Control(pDX, IDC_ERASEMETHOD, m_EraseMethod);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(EraseOption, CDialog)
//{{AFX_MSG_MAP(EraseOption)
ON_BN_CLICKED(IDC_ERASE, OnErase)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// EraseOption message handlers
BOOL NERO_CALLBACK_ATTR EraseOption::ProgressCallback(void *pUserData, DWORD dwProgressInPercent)
{
// the NeroAPI updates the current progress counter
// set the progress bar to the percentage value that was passed to this function
((EraseOption*)pUserData)->m_pgsEraseProgress.SetPos(dwProgressInPercent);
return true;
}
void EraseOption::OnErase()
{
CChtRecNeroDlg *pDlg =(CChtRecNeroDlg*)theApp.m_pMainWnd; //(CChtRecNeroDlg*)AfxGetMainWnd();
if ( pDlg != NULL )
{
if(m_EraseMethod.GetCurSel()==0)
{
pDlg->m_mode=NEROAPI_ERASE_QUICK;
}
else{
pDlg->m_mode=NEROAPI_ERASE_ENTIRE;
}
// check whether a valid handle was returned
if (!pDlg->m_ndhDeviceHandle)
{
// no handle available; tell the user what happened
//AppendString("Device could not be opened: "+(CString)nsdiDevice->nsdiDeviceName);
}
else
{
m_pgsEraseProgress.SetRange(0,100);
m_Cancel.EnableWindow(false);
m_Erase.EnableWindow(false);
m_pgsEraseProgress.SetPos(0);
int res;
m_time = NeroGetCDRWErasingTime(pDlg->m_ndhDeviceHandle,pDlg->m_mode);
TRACE("zx is %d\n",m_time);
SetTimer(1,1000,NULL);
switch (m_time)
{
case -1:
AfxMessageBox("No disc inserted!");
res = DLG_RETURN_RESTART;
break;
case -2:
AfxMessageBox("This recorder does not support rewritable discs!");
res = DLG_RETURN_EXIT;
break;
case -3:
AfxMessageBox("The inserted disc is NOT rewritable!");
res = DLG_RETURN_RESTART;
//EndDialog(IDD_ERASEOPTION);//++++1008
break;
default:
if (m_time < 0)
{
AfxMessageBox ("Unknown error while trying to erase disc!");
}
}
PTHREADPARA multipara=new THREADPARA;
multipara->Handle=pDlg->m_ndhDeviceHandle;
multipara->mode=pDlg->m_mode;
multipara->pThis=this;
AfxBeginThread(ShowStep,(LPVOID)multipara,THREAD_PRIORITY_NORMAL,0,0,NULL);
}
}
}
BOOL EraseOption::OnInitDialog()
{
CDialog::OnInitDialog();
m_EraseMethod.SelectString(-1,"快速");
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void EraseOption::OnTimer(UINT nIDEvent)
{
m_pos=(float)m_step/(float)m_time*100;
TRACE("DFR %d\n",static_cast<int>(m_pos));
m_pgsEraseProgress.SetPos(static_cast<int>(m_pos));
m_step++;
CDialog::OnTimer(nIDEvent);
}
UINT EraseOption::ShowStep(LPVOID pParam)
{
NeroEraseDisc (((PTHREADPARA)pParam)->Handle,((PTHREADPARA)pParam)->mode, NEDF_DISABLE_EJECT, NULL);
NeroCloseDevice(((PTHREADPARA)pParam)->Handle);
((PTHREADPARA)pParam)->pThis->m_Cancel.EnableWindow(true);
((PTHREADPARA)pParam)->pThis->m_Erase.EnableWindow(true);
delete pParam;
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -