SpeedComboBox.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /******************************************************************************
  2. |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. |* PARTICULAR PURPOSE.
  6. |*
  7. |* Copyright 1995-2005 Nero AG. All Rights Reserved.
  8. |*-----------------------------------------------------------------------------
  9. |* NeroSDK / NVAPIExample
  10. |*
  11. |* PROGRAM: SpeedComboBox.cpp
  12. |*
  13. |* PURPOSE: A combobox that holds all available speeds for a particular
  14. |* recorder.
  15. ******************************************************************************/
  16. #include "stdafx.h"
  17. #include "NVAPIExample.h"
  18. #include "SpeedComboBox.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. BEGIN_MESSAGE_MAP(CSpeedComboBox, CComboBox)
  25. //{{AFX_MSG_MAP(CSpeedComboBox)
  26. // NOTE - the ClassWizard will add and remove mapping macros here.
  27. //}}AFX_MSG_MAP
  28. END_MESSAGE_MAP()
  29. // This method is used to refresh the speeds of this combobox using the
  30. // recorder passed as parameter.
  31. //
  32. void CSpeedComboBox::RefreshSpeeds (const NERO_SCSI_DEVICE_INFO * pnsdi)
  33. {
  34. // First clear the combobox.
  35. //
  36. ResetContent ();
  37. if (pnsdi != NULL)
  38. {
  39. // Open the device...
  40. //
  41. NERO_DEVICEHANDLE hDevice = NeroOpenDevice (pnsdi);
  42. if (hDevice != NULL)
  43. {
  44. // Get the speeds...
  45. //
  46. NERO_SPEED_INFOS * pSpeeds = NeroGetAvailableSpeeds (hDevice,
  47. ACCESSTYPE_WRITE,
  48. MEDIA_CD,
  49. NULL);
  50. if (pSpeeds != NULL)
  51. {
  52. CString sSpeed;
  53. // Loop through all available speeds and add them to
  54. // the combobox.
  55. //
  56. for (DWORD i = 0; i < pSpeeds->nsiNumSupportedSpeeds; i ++)
  57. {
  58. sSpeed.Format ("%d", pSpeeds->nsiSupportedSpeeds[i]);
  59. int iIndex = AddString (sSpeed);
  60. if (iIndex != CB_ERR)
  61. {
  62. // Set the item data to be the speed itself in X.
  63. //
  64. SetItemData (iIndex, pSpeeds->nsiSupportedSpeeds[i]);
  65. }
  66. }
  67. NeroFreeMem (pSpeeds);
  68. }
  69. NeroCloseDevice (hDevice);
  70. }
  71. }
  72. // Always add the "Maximum" speed with a value of 0.
  73. //
  74. int iIndex = AddString ("Maximum");
  75. if (iIndex != CB_ERR)
  76. {
  77. SetItemData (iIndex, 0);
  78. }
  79. SetCurSel (iIndex);
  80. }
  81. // Get the currently selected speed.
  82. //
  83. DWORD CSpeedComboBox::GetSelectedSpeed (void) const
  84. {
  85. int iCurSel = GetCurSel ();
  86. return (iCurSel == -1)? 0: GetItemData (iCurSel);
  87. }