| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005 |
- /******************************************************************************
- |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
- |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
- |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
- |* PARTICULAR PURPOSE.
- |*
- |* Copyright 1995-2005 Nero AG. All Rights Reserved.
- |*-----------------------------------------------------------------------------
- |* NeroSDK / NeroCBUI
- |*
- |* PROGRAM: TestNeroCBUI
- |*
- |* PURPOSE: Sample application for the use of NeroCBUI
- ******************************************************************************/
- #include "stdafx.h"
- #include "TestNeroCBUI.h"
- #include "Dlg.h"
- #include "BurnDlg.h"
- #include "PropertyPageBurnSettings.h"
- #include "PropertyPageImageInfo.h"
- #include "TestNeroCBUI.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlg dialog
- CDlg::CDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDlg)
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- m_pRoboInfos = NULL;
- /** This should be not possible yet. */
- if(SUCCEEDED(m_pRoboInfos.CoCreateInstance(__uuidof(RoboInfos))))
- {
- ASSERT(FALSE);
- m_pRoboInfos = NULL;
- }
- }
- CDlg::~CDlg ()
- {
- m_pRoboInfos = NULL;
- }
- void CDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDlg)
- DDX_Control(pDX, IDC_BURN_WIZARD_MODE, c_WizardMode);
- DDX_Control(pDX, IDC_MEDIA_COMBO, m_MediaCombo);
- DDX_Control(pDX, IDC_MODAL_ERASE_DISC, c_ModalEraseDisc);
- DDX_Control(pDX, IDC_LANG_COMBO, m_Combo);
- DDX_Control(pDX, IDC_TEST_ERASE_DISC, c_TestEraseDisc);
- DDX_Control(pDX, IDC_TEST_DISC_INFO, c_TestDiscInfo);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDlg, CDialog)
- //{{AFX_MSG_MAP(CDlg)
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_TEST_ERASE_DISC, OnTestEraseDisc)
- ON_BN_CLICKED(IDC_TEST_DISC_INFO, OnTestDiscInfo)
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_TEST_BURN_SETTINGS, OnTestBurnSettings)
- ON_BN_CLICKED(IDC_TEST_BURN_SETTINGS_OLE, OnTestBurnSettingsOle)
- ON_BN_CLICKED(IDC_TEST_BURN_PROGRESS, OnTestBurnProgress)
- ON_BN_CLICKED(IDC_TEST_IMAGE_INFO, OnTestImageInfo)
- ON_BN_CLICKED(IDC_TEST_CHOOSE_RECORDER, OnTestChooseRecorder)
- ON_BN_CLICKED(IDC_TEST_CHOOSE_SESSION, OnTestChooseSession)
- ON_CBN_SELCHANGE(IDC_LANG_COMBO, OnSelchangeLangCombo)
- ON_BN_CLICKED(IDC_TEST_ERASE_DISC_MODELESS, OnTestEraseDiscModeless)
- ON_BN_CLICKED(IDC_TEST_WAIT_FOR_MEDIA, OnTestWaitForMedia)
- ON_CBN_SELCHANGE(IDC_MEDIA_COMBO, OnSelchangeMediaCombo)
- ON_CBN_SELCHANGE(IDC_RECORDER, OnSelchangeRecorder)
- ON_BN_CLICKED(IDC_TEST_IMAGE_INFO_OLE, OnTestImageInfoOle)
- ON_BN_CLICKED(IDC_TEST_CONFIGURE_ROBOT, OnTestConfigureRobot)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDlg message handlers
- BOOL CDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
-
- BOOL bSuccess = FALSE;
- if (SUCCEEDED (m_pRecorderCombobox.CoCreateInstance (__uuidof (RecorderCombobox))))
- {
- CComQIPtr<IChildWindow> pChildWindow (m_pRecorderCombobox);
- CComBSTR bstr ("Custom append item");
- m_pRecorderCombobox->AppendCustomEntry (m_hIcon, bstr, (void *) 1);
- bstr = "Custom prepend item";
- m_pRecorderCombobox->PrependCustomEntry (m_hIcon, bstr, (void *) 1);
-
- if (pChildWindow)
- {
- pChildWindow.p->Subclass (GetDlgItem (IDC_RECORDER)->m_hWnd, &bSuccess);
- }
- // set this object as callback receiver
- m_pRecorderCombobox.p->put_Callbacks(this);
- }
-
- if (bSuccess && SUCCEEDED (m_pWriteSpeedCombobox.CoCreateInstance (__uuidof (SpeedCombobox))))
- {
- // set the default media type
- m_pWriteSpeedCombobox.p->put_MediaType(MEDIA_CD);
- m_pWriteSpeedCombobox->put_HideWhenEmpty (FALSE);
-
- CComQIPtr<IChildWindow> pChildWindow (m_pWriteSpeedCombobox);
-
- if (pChildWindow)
- {
- pChildWindow.p->Subclass (GetDlgItem (IDC_WRITESPEEDS)->m_hWnd, &bSuccess);
- }
- }
-
- BOOL bEnable = bSuccess && ((CApp*)AfxGetApp)->m_bNeroAPIInitOk;
- c_TestDiscInfo.EnableWindow (bEnable);
- c_TestEraseDisc.EnableWindow (bEnable);
- c_ModalEraseDisc.SetCheck (1);
- c_WizardMode.SetCheck (1);
- m_MediaCombo.SetCurSel(0);
- return TRUE; // return TRUE unless you set the focus to a control
- }
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
- void CDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CDlg::OnTestEraseDisc()
- {
- NEROAPI_CDRW_ERASE_MODE mode = NEROAPI_ERASE_QUICK;
-
- // Declare a smart pointer to INERO_SCSI_DEVICE_INFO interface. Create
- // an instance of DiscInfoDlg class.
- //
- CComPtr<INERO_SCSI_DEVICE_INFO> pNSDI;
- if (SUCCEEDED (pNSDI.CoCreateInstance (__uuidof (EraseSettingsDlg))))
- {
- CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI (m_pRecorderCombobox);
- ATLASSERT (pRecorderNSDI);
- LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
- pRecorderNSDI.p->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
- pNSDI->put_NERO_SCSI_DEVICE_INFO ( pDeviceInfo );
- CComQIPtr<IEraseSettingsDlg> pEraseSettingsDlg (pNSDI);
- ATLASSERT (pEraseSettingsDlg.p != NULL);
- bool bModelessErase = c_ModalEraseDisc.GetCheck () == 0;
- pEraseSettingsDlg->put_ModelessErase (bModelessErase);
-
- if (bModelessErase)
- {
- pEraseSettingsDlg->put_Callbacks (this);
- }
- // Declare a smart pointer to IModalDialog interface and call its
- // DoModal method.
- //
- CComPtr<IModalDialog> pModalDialog;
- int iRet = 0;
- if(SUCCEEDED(pNSDI.QueryInterface(&pModalDialog)))
- pModalDialog->DoModal (m_hWnd, &iRet);
-
- if (!bModelessErase)
- {
- // 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 ("Selected device was \"%s\".", (pDeviceInfo != NULL && pDeviceInfo->nsdiDeviceName[0] != '\0')? pDeviceInfo->nsdiDeviceName: "[no device selected]");
-
- str.Format ("%s\nUser selected OK and erase process completed successfully!", 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);
- }
- }
- }
- else
- {
- CComQIPtr<IEraseSettingsDlg2> pEraseSettingsDlg2 (pNSDI);
- if(pEraseSettingsDlg2.p)
- {
- HWND hWndDlg;
- pEraseSettingsDlg2->get_ModelessDlgHWND(&hWndDlg);
- ATLASSERT(hWndDlg);
- /*
- if(hWndDlg)
- VERIFY(::CloseWindow(hWndDlg));
- */
- }
- }
- }
- }
- void CDlg::OnTestDiscInfo()
- {
- // Declare a smart pointer to INERO_SCSI_DEVICE_INFO interface. Create
- // an instance of DiscInfoDlg class.
- //
- CComPtr<INERO_SCSI_DEVICE_INFO> pNSDI;
- if (SUCCEEDED (pNSDI.CoCreateInstance (__uuidof (DiscInfoDlg))))
- {
- CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI (m_pRecorderCombobox);
- ATLASSERT (pRecorderNSDI);
- LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
- pRecorderNSDI.p->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
- pNSDI->put_NERO_SCSI_DEVICE_INFO ( pDeviceInfo );
- // Declare a smart pointer to IModalDialog interface and call its
- // DoModal method.
- //
- CComPtr<IModalDialog> pModalDialog;
- int iRet = 0;
- if(SUCCEEDED(pNSDI->QueryInterface(&pModalDialog)))
- 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 ("Everything was fine.\nThe user's last 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::OnDestroy()
- {
- CDialog::OnDestroy();
-
- m_pRecorderCombobox = NULL;
- m_pWriteSpeedCombobox = NULL;
- }
- void CDlg::OnTestBurnSettings()
- {
- CComPtr<IBurnSettings> pBurnSettings;
- if (SUCCEEDED (pBurnSettings.CoCreateInstance (__uuidof (BurnSettings))))
- {
- pBurnSettings.p->put_BurnFlags (NBF_BUF_UNDERRUN_PROT|NBF_SPEED_IN_KBS|NBF_DAO|NBF_VERIFY);
- }
- CPropertyPageBurnSettings page;
- if (page.m_pMfcPropertyPage != NULL)
- {
- CComQIPtr<INERO_SCSI_DEVICE_INFO> pNSDI (page.m_pMfcPropertyPage);
- ATLASSERT (pNSDI);
- CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI (m_pRecorderCombobox);
- ATLASSERT (pRecorderNSDI);
- LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
- pRecorderNSDI.p->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
- pNSDI.p->put_NERO_SCSI_DEVICE_INFO (pDeviceInfo);
- CComQIPtr<IBurnSettingsDlg> pBurnSettingsDlg (page.m_pMfcPropertyPage);
- pBurnSettingsDlg.p->put_MediaType (SelectedMediaType());
- pBurnSettingsDlg.p->put_BurnSettings (pBurnSettings);
- CPropertySheet sheet;
-
- sheet.AddPage (&page);
- if (IDOK == sheet.DoModal ())
- {
- DWORD dwBurnFlags = 0;
- DWORD dwSpeed = 0;
-
- // These values aren't displayed. They only serve for debugging
- // purposes.
- //
- pBurnSettings.p->get_BurnFlags (&dwBurnFlags);
- pBurnSettings.p->get_Speed (&dwSpeed);
- }
- }
- }
- void CDlg::OnTestBurnSettingsOle()
- {
- // Create BurnSettings object.
- //
- CComPtr<IBurnSettings> pBurnSettings;
- if (SUCCEEDED (pBurnSettings.CoCreateInstance (__uuidof (BurnSettings))))
- {
- pBurnSettings.p->put_BurnFlags (NBF_BUF_UNDERRUN_PROT|NBF_SPEED_IN_KBS|NBF_DAO|NBF_VERIFY);
- }
- // Create BurnSettingsParam object and fill it with data.
- //
- CComPtr<IBurnSettingsDlg> pParam;
- if (SUCCEEDED (pParam.CoCreateInstance (__uuidof (BurnSettingsDlgParam))))
- {
- pParam->put_BurnSettings (pBurnSettings);
- pParam->put_MediaType (SelectedMediaType ());
-
- CComQIPtr<INERO_SCSI_DEVICE_INFO> pNSDIParam (pParam);
- ATLASSERT (pNSDIParam);
-
- CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI (m_pRecorderCombobox);
- ATLASSERT (pRecorderNSDI);
-
- LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
- pRecorderNSDI->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
-
- pNSDIParam->put_NERO_SCSI_DEVICE_INFO (pDeviceInfo);
- }
- IUnknown * pUnk = pParam;
- OleCreatePropertyFrame (m_hWnd, 0, 0, L"Title", 1, &pUnk, 1, (LPCLSID) &__uuidof (BurnSettingsDlg), 0, NULL, NULL);
- }
- void CDlg::OnTestBurnProgress()
- {
- CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI (m_pRecorderCombobox);
- ATLASSERT (pRecorderNSDI);
- LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
- pRecorderNSDI.p->get_NERO_SCSI_DEVICE_INFO (&pDeviceInfo);
- #if 1 // test the burn progress dialog of NeroCBUI
- 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 if(csMedia=="BD")
- {
- mediatype=MEDIA_BD_ANY;
- }
- 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);
- }
- }
- }
- void CDlg::OnTestConfigureRobot()
- {
- /** Create robo configure dialog. */
- CComPtr<IConfigureRoboDlg> pRoboDlg;
- HRESULT hResult = pRoboDlg.CoCreateInstance(__uuidof(ConfigureRoboDlg));
- if(SUCCEEDED(hResult))
- {
- CComQIPtr<IConfigureRoboDlgCallbacks> pConfRoboDlgCallbacks(this);
- pRoboDlg->put_Callbacks(pConfRoboDlgCallbacks);
- pRoboDlg->put_RoboInfos(m_pRoboInfos);
-
- // Declare a smart pointer to IModalDialog interface and call its DoModal method.
- CComPtr<IModalDialog> pModalDialog;
- int iRet = 0;
- hResult = pRoboDlg->QueryInterface(&pModalDialog);
- if(SUCCEEDED(hResult))
- pModalDialog->DoModal(m_hWnd,&iRet);
- switch (iRet)
- {
- case IDOK:
- {
- DWORD dwCount = 0;
- CString csTemp = "";
- pRoboDlg->get_RoboInfos(&(m_pRoboInfos.p));
- m_pRoboInfos->get_Count(&dwCount);
- csTemp.Format("The dialog was confirmed.\nRecevied %d recorder(s) with robot driver associated.", dwCount);
- AfxMessageBox(csTemp);
- }
- break;
-
- case IDCANCEL:
- AfxMessageBox ("The dialog was canceled!");
- break;
-
- default:
- {
- CString str;
- str.Format ("There was an error displaying the dialog box!");
- AfxMessageBox (str);
- }
- }
- }
- else
- {
- CString msg = "????";
- switch(hResult)
- {
- case REGDB_E_CLASSNOTREG: msg = "Class not registered!!!"; break;
- case CLASS_E_NOAGGREGATION: msg = "No aggregation!!!"; break;
- case E_NOINTERFACE: msg = "No interface!!!"; break;
- default: ASSERT(FALSE); break;
- }
- AfxMessageBox(msg);
- }
- pRoboDlg = NULL;
- }
- STDMETHODIMP CDlg::OnConfigureRobot(IRoboInfo* pRoboInfo)
- {
- ASSERT(pRoboInfo != NULL);
- if(pRoboInfo != NULL)
- {
- CString csInfo = GetRoboInfoString(pRoboInfo);
- CString csMsg;
- csMsg.Format("CDlg::OnConfigureRobot\n%s", csInfo);
- AfxMessageBox(csMsg);
- }
- return S_OK;
- }
- STDMETHODIMP CDlg::OnTestRobot(IRoboInfo* pRoboInfo)
- {
- ASSERT(pRoboInfo != NULL);
- if(pRoboInfo != NULL)
- {
- CString csInfo = GetRoboInfoString(pRoboInfo);
- CString csMsg;
- csMsg.Format("CDlg::OnTestRobot\n%s", csInfo);
- AfxMessageBox(csMsg);
- }
- return S_OK;
- }
- STDMETHODIMP CDlg::OnRobotPortChanged(IRoboInfo* pRoboInfo)
- {
- ASSERT(pRoboInfo != NULL);
- if(pRoboInfo != NULL)
- {
- CString csInfo = GetRoboInfoString(pRoboInfo);
- CString csMsg;
- csMsg.Format("CDlg::OnRobotPortChanged\n%s", csInfo);
- AfxMessageBox(csMsg);
- }
- return S_OK;
- }
- STDMETHODIMP CDlg::OnRobotBlankCdrw(IRoboInfo* pRoboInfo, BOOL bChecked)
- {
- ASSERT(pRoboInfo != NULL);
- if(pRoboInfo != NULL)
- {
- CString csInfo = GetRoboInfoString(pRoboInfo);
- CString csMsg;
- csMsg.Format("CDlg::OnRobotBlankCdrw\n%s\nnChecked: %d", csInfo, bChecked);
- AfxMessageBox(csMsg);
- }
- return S_OK;
- }
- CString CDlg::GetRoboInfoString(IRoboInfo* pRoboInfo)
- {
- CString csInfo;
- ASSERT(pRoboInfo != NULL);
- if(pRoboInfo != NULL)
- {
- /** Get device name... */
- LPNERO_SCSI_DEVICE_INFO pDeviceInfo = NULL;
- CComQIPtr<INERO_SCSI_DEVICE_INFO> pRecorderNSDI(pRoboInfo);
- ATLASSERT(pRecorderNSDI.p != NULL);
- if(pRecorderNSDI.p != NULL)
- pRecorderNSDI->get_NERO_SCSI_DEVICE_INFO(&pDeviceInfo);
- CString csRecName = (pDeviceInfo != NULL) ? pDeviceInfo->nsdiDeviceName : "Unknown Recorder Device!";
-
- CComBSTR bstrName;
- USES_CONVERSION;
-
- /** and robo name ...*/
- pRoboInfo->get_RoboName(&bstrName);
- CString csRoboName = (bstrName != NULL) ? W2A(bstrName): "";
- if(csRoboName.IsEmpty())
- csRoboName = "<No Robot>";
- /** and printer name...*/
- pRoboInfo->get_PrinterName(&bstrName);
- CString csPrinterName = (bstrName != NULL) ? W2A(bstrName): "";
- if(csPrinterName.IsEmpty())
- csPrinterName = "<No Printer>";
- /** and port type...*/
- DWORD dwPortType;
- pRoboInfo->get_PortType(&dwPortType);
- /** and port number. */
- DWORD dwPortNo;
- pRoboInfo->get_PortNumber(&dwPortNo);
-
- /** Assembly the info message. */
- csInfo.Format("\nRecorder:\t%s\nRobot:\t\t%s\nPrinter:\t\t%s\nPort Type:\t%d\nPort Number:\t%d", csRecName, csRoboName, csPrinterName, dwPortType, dwPortNo);
- }
-
- return csInfo;
- }
|