📄 dlg.cpp
字号:
CBurnDlg dlg;
dlg.m_pDeviceInfo = pDeviceInfo;
dlg.m_bWizardMode = c_WizardMode.GetCheck () != 0;
dlg.DoModal ();
#else // test the UserDlgHandler of NeroCBUI (don't forget to adapt the path to the image)
((CApp *)AfxGetApp ())->SetUserDlgParentHWND (m_hWnd);
((CApp *)AfxGetApp ())->ResetUserDlgAbort();
NERO_WRITE_IMAGE m_neroImage;
memset(&m_neroImage,0,sizeof(NERO_WRITE_IMAGE));
m_neroImage.nwiImageFileName[0] = '\0';
m_neroImage.nwiLongImageFileName = "c:\\test.nrg";
NERO_DEVICEHANDLE handle = NeroOpenDevice(pDeviceInfo);
NERO_PROGRESS * progress = NeroCreateProgress ();
if(handle)
{
int result = NeroBurn(handle,NERO_BURN_IMAGE_MEDIA, &m_neroImage, NBF_WRITE|NBF_DETECT_NON_EMPTY_CDRW|NBF_DAO,0, progress);
char * p = NeroGetLastError ();
if (p)
{
AfxMessageBox (p);
}
NeroFreeMem (p);
}
else
{
ASSERT(FALSE);
}
NeroFreeMem (progress);
#endif
}
void CDlg::OnTestImageInfo()
{
CPropertyPageImageInfo page;
CComQIPtr<IImageInfoDlg> pImageInfoDlg (page.m_pMfcPropertyPage);
ATLASSERT (pImageInfoDlg.p != NULL);
if (pImageInfoDlg.p != NULL)
{
static char szFilter[] = "Nero Images (*.nrg)|*.nrg|ISO Images (*.iso)|*.iso|All Files (*.*)|*.*||";
CFileDialog fd (TRUE,"nrg",NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilter, this);
if (IDOK == fd.DoModal ())
{
CComBSTR bstrFilename (fd.GetPathName ());
pImageInfoDlg->put_ImageFilename (bstrFilename);
CPropertySheet sheet;
sheet.AddPage (&page);
if (IDOK == sheet.DoModal ())
{
}
}
}
}
void CDlg::OnTestChooseRecorder()
{
CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI (m_pRecorderCombobox);
ATLASSERT (pRecorderNSDI);
LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
pRecorderNSDI.p->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
CComPtr<INERO_SCSI_DEVICE_INFO> pNSDI;
if (SUCCEEDED (pNSDI.CoCreateInstance (__uuidof (ChooseRecorderDlg))))
{
// Set the initial selection blindly to zero-th device.
//
pNSDI->put_NERO_SCSI_DEVICE_INFO (pDeviceInfo);
// Declare a smart pointer to IModalDialog interface and call its
// DoModal method.
//
CComQIPtr<IModalDialog> pModalDialog (pNSDI);
ATLASSERT (pModalDialog.p != NULL);
int iRet = 0;
pModalDialog->DoModal (m_hWnd, &iRet);
// Display different information depending on the return value.
//
switch (iRet)
{
case IDOK:
{
CString str, sDevice;
NERO_SCSI_DEVICE_INFO * pDeviceInfo;
// Get the last current selection in the recorder combobox.
//
pNSDI->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
sDevice.Format ("%s", (pDeviceInfo != NULL && pDeviceInfo->nsdiDeviceName[0] != '\0')? pDeviceInfo->nsdiDeviceName: "[no device selected]");
str.Format ("The user's selection was \"%s\".", sDevice);
AfxMessageBox (str);
}
break;
case IDCANCEL:
AfxMessageBox ("The dialog was canceled!");
break;
default:
{
CString str;
str.Format ("There was an error displaying the dialog box!");
AfxMessageBox (str);
}
}
}
}
void CDlg::OnTestChooseSession()
{
CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI (m_pRecorderCombobox);
ATLASSERT (pRecorderNSDI);
LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
pRecorderNSDI.p->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
CComPtr<INERO_SCSI_DEVICE_INFO> pNSDI;
if (SUCCEEDED (pNSDI.CoCreateInstance (__uuidof (ChooseSessionDlg))))
{
// Set the initial selection blindly to zero-th device.
//
pNSDI->put_NERO_SCSI_DEVICE_INFO (pDeviceInfo);
// Declare a smart pointer to IModalDialog interface and call its
// DoModal method.
//
CComQIPtr<IModalDialog> pModalDialog (pNSDI);
ATLASSERT (pModalDialog.p != NULL);
int iRet = 0;
pModalDialog->DoModal (m_hWnd, &iRet);
// Display different information depending on the return value.
//
switch (iRet)
{
case IDOK:
{
CString str;
CComQIPtr<IChooseSessionDlg> pChooseSessionDlg (pNSDI);
ATLASSERT (pChooseSessionDlg.p != NULL);
DWORD dwTrackNumber;
pChooseSessionDlg->get_TrackNumber (&dwTrackNumber);
str.Format ("The user selected track #%d.", dwTrackNumber);
AfxMessageBox (str);
}
break;
case IDCANCEL:
AfxMessageBox ("The dialog was canceled!");
break;
default:
{
CString str;
str.Format ("There was an error displaying the dialog box!");
AfxMessageBox (str);
}
}
}
}
void CDlg::OnSelchangeLangCombo()
{
int iSel=m_Combo.GetCurSel();
if(iSel>=0)
{
int iLen = m_Combo.GetLBTextLen(iSel);
CString csLang;
m_Combo.GetLBText(iSel,csLang);
CComPtr<IInitSettings> pInitSettings;
// we can safely create a new instance of the InitSettings object,
// since NeroCBUI will only allow one instance of this object and therefore
// we will receive the already existing object
if (SUCCEEDED (pInitSettings.CoCreateInstance (__uuidof (InitSettings))))
{
if(pInitSettings->put_LanguageCode((const signed char*)(const char*)csLang)!=S_OK)
{
AfxMessageBox("Setting the language failed!");
m_Combo.SetCurSel(-1);
}
}
else
{
AfxMessageBox("Failed to get an instance of the IInitSettings interface!");
}
}
}
void CDlg::OnTestEraseDiscModeless()
{
// Get the selected recorder from the combo and set it to the
// object.
//
CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI (m_pRecorderCombobox);
ATLASSERT (pRecorderNSDI);
LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
pRecorderNSDI->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
// Create EraseDiscDlg object.
//
CComPtr<IModelessDialog> pModelessEraseDiscDialog;
if (SUCCEEDED (pModelessEraseDiscDialog.CoCreateInstance (__uuidof (EraseDiscDlg))))
{
CComQIPtr<IEraseDiscDlg3> pEraseDiscDlg (pModelessEraseDiscDialog);
ATLASSERT (pEraseDiscDlg.p != NULL);
// Let the dialog know the device. Don't use direct handle, it is
// more convenient this way.
//
CComQIPtr<INERO_SCSI_DEVICE_INFO> pNSDI (pModelessEraseDiscDialog);
ATLASSERT (pNSDI.p != NULL);
pNSDI->put_NERO_SCSI_DEVICE_INFO (pDeviceInfo);
// This is a trick as well as a whole IEraseDiscCallbacks interface
// implementation, but it will do.
//
pEraseDiscDlg->put_Callbacks (this);
// Create the dialog.
//
HWND hWndDlg;
pModelessEraseDiscDialog->Create (m_hWnd, NULL, &hWndDlg);
}
}
STDMETHODIMP CDlg::OnEraseDone (IEraseDiscDlg * pEraseDiscDlg)
{
// Erase process has been completed.
//
CString str;
CComBSTR bstr;
USES_CONVERSION;
int iResult = 0;
// Get the results...
//
pEraseDiscDlg->get_ErasingResultString (&bstr);
pEraseDiscDlg->get_ErasingResult (&iResult);
// Format and display the results...
//
str.Format ("Reported result was: %d.\nReported message was: \"%s\".", iResult, W2CA (bstr));
AfxMessageBox (str);
return S_OK;
}
STDMETHODIMP CDlg::OnFilterRecorder(LPCNERO_SCSI_DEVICE_INFO pDeviceInfo, BOOL * pbAccept)
{
ASSERT (pDeviceInfo != NULL);
ASSERT (pbAccept != NULL);
// Filter out the devices that are not capable of burning.
//
if (pDeviceInfo->nsdiDevType == NEA_SCSI_DEVTYPE_CDROM ||
pDeviceInfo->nsdiDevType == NEA_SCSI_DEVTYPE_UNKNOWN ||
pDeviceInfo->nsdiDevType == NEA_SCSI_DEVTYPE_UNSUPPORTED_WORM ||
(pDeviceInfo->nsdiCapabilities & NSDI_ALLOWED) == 0)
{
// We don't want CDROMs, unknown and unsupported drives
*pbAccept = FALSE;
}
else
{
*pbAccept = TRUE;
}
return S_OK;
}
STDMETHODIMP CDlg::OnFilterEnd()
{
return S_OK;
}
STDMETHODIMP CDlg::OnContentRefreshed()
{
// here we check, if the selected recorder changed and set the selected recorder
// in the write speed combo box
CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI (m_pRecorderCombobox);
ATLASSERT (pRecorderNSDI);
LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
pRecorderNSDI->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
CComQIPtr<INERO_SCSI_DEVICE_INFO> pSpeedNSDI (m_pWriteSpeedCombobox);
ATLASSERT (pSpeedNSDI);
pSpeedNSDI->put_NERO_SCSI_DEVICE_INFO (pDeviceInfo);
return S_OK;
}
STDMETHODIMP CDlg::OnCurSelInUseStatusChange(BOOL bInUse)
{
// normally one would deactivate the burn button if bInUse
// is TRUE and activate it otherwise
return S_OK;
}
void CDlg::OnTestWaitForMedia()
{
// Get the selected recorder from the combo.
//
CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI (m_pRecorderCombobox);
ATLASSERT (pRecorderNSDI);
LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
pRecorderNSDI->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
if (pDeviceInfo != NULL)
{
NERO_DEVICEHANDLE deviceHandle = NeroOpenDevice (pDeviceInfo);
if (deviceHandle != NULL)
{
CComPtr<IWaitForMediaDlg> pWaitForMedia;
if (SUCCEEDED (pWaitForMedia.CoCreateInstance (__uuidof (WaitForMediaDlg))))
{
BOOL bAbort = FALSE;
pWaitForMedia->WaitForMedia (m_hWnd, deviceHandle, SelectedMediaType(), NBF_WRITE, NULL, &bAbort);
CString str;
str.Format ("The outcome of the operation was %sto abort!", bAbort? "": "NOT ");
AfxMessageBox (str);
}
NeroCloseDevice (deviceHandle);
}
}
}
void CDlg::OnSelchangeMediaCombo()
{
m_pWriteSpeedCombobox.p->put_MediaType(SelectedMediaType());
}
NERO_MEDIA_TYPE CDlg::SelectedMediaType()
{
NERO_MEDIA_TYPE mediatype=MEDIA_CD; // default value
int iSel=m_MediaCombo.GetCurSel();
if(iSel>=0)
{
CString csMedia;
m_MediaCombo.GetLBText(iSel,csMedia);
if(csMedia=="CD")
{
mediatype=MEDIA_CD;
}
else if(csMedia=="DVD")
{
mediatype=MEDIA_DVD_ANY;
}
else if(csMedia=="HDB")
{
mediatype=MEDIA_HDB;
}
else
{
ASSERT(false);
}
}
return mediatype;
}
void CDlg::OnSelchangeRecorder()
{
OnContentRefreshed ();
}
void CDlg::OnTestImageInfoOle()
{
static char szFilter[] = "Nero Images (*.nrg)|*.nrg|ISO Images (*.iso)|*.iso|All Files (*.*)|*.*||";
CFileDialog fd (TRUE,"nrg",NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilter, this);
if (IDOK == fd.DoModal ())
{
CComPtr<IImageInfoDlg> pParam;
if (SUCCEEDED (pParam.CoCreateInstance (__uuidof (ImageInfoDlgParam))))
{
CComBSTR bstrFilename (fd.GetPathName ());
pParam->put_ImageFilename (bstrFilename);
IUnknown * pUnk = pParam;
OleCreatePropertyFrame (m_hWnd, 0, 0, L"Title", 1, &pUnk, 1, (LPCLSID) &__uuidof (ImageInfoDlg), 0, NULL, NULL);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -