Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.1 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. /*++
  3. Module Name:
  4. RemLic.cpp
  5. Abstract:
  6. This Module contains the implementation of the CRemoveLicenses Dialog class
  7. (Dialog box used for adding keypacks)
  8. Author:
  9. Arathi Kundapur (v-akunda) 22-Feb-1998
  10. Revision History:
  11. --*/
  12. #include "stdafx.h"
  13. #include "licmgr.h"
  14. #include "defines.h"
  15. #include "lsserver.h"
  16. #include "addkp.h"
  17. #include "RemLic.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CRemoveLicenses dialog
  25. CRemoveLicenses::CRemoveLicenses(CWnd* pParent /*=NULL*/)
  26. : CDialog(CRemoveLicenses::IDD, pParent)
  27. {
  28. //{{AFX_DATA_INIT(CRemoveLicenses)
  29. // NOTE: the ClassWizard will add member initialization here
  30. m_LicensePack = _T("");
  31. m_NumLicenses = 0;
  32. m_pAddKeyPack = NULL;
  33. //}}AFX_DATA_INIT
  34. }
  35. CRemoveLicenses::CRemoveLicenses(CAddKeyPack * pAddKeyPack,CWnd* pParent /*=NULL*/)
  36. : CDialog(CRemoveLicenses::IDD, pParent)
  37. {
  38. //{{AFX_DATA_INIT(CAddLicenses)
  39. m_LicensePack = _T("");
  40. m_NumLicenses = 0;
  41. m_pAddKeyPack = pAddKeyPack;
  42. //}}AFX_DATA_INIT
  43. }
  44. void CRemoveLicenses::DoDataExchange(CDataExchange* pDX)
  45. {
  46. CDialog::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(CRemoveLicenses)
  48. DDX_Control(pDX, IDC_SPIN_LICNESES, m_SpinCtrl);
  49. DDX_Control(pDX, IDC_LICNESE_PACK, m_LicenseCombo);
  50. DDX_CBString(pDX, IDC_LICNESE_PACK, m_LicensePack);
  51. DDX_Text(pDX, IDC_NUM_LICENSES, m_NumLicenses);
  52. DDV_MinMaxDWord(pDX, m_NumLicenses, 0, 9999);
  53. //}}AFX_DATA_MAP
  54. }
  55. BEGIN_MESSAGE_MAP(CRemoveLicenses, CDialog)
  56. //{{AFX_MSG_MAP(CRemoveLicenses)
  57. ON_CBN_SELCHANGE(IDC_LICNESE_PACK, OnSelchangeLicnesePack)
  58. ON_BN_CLICKED(IDC_HELP4, OnHelp)
  59. //}}AFX_MSG_MAP
  60. END_MESSAGE_MAP()
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CRemoveLicenses message handlers
  63. BOOL CRemoveLicenses::OnInitDialog()
  64. {
  65. CDialog::OnInitDialog();
  66. CString ProdDesc;
  67. if(NULL == m_pAddKeyPack)
  68. return FALSE;
  69. int nCount = m_pAddKeyPack->m_LicenseCombo.GetCount( );
  70. for(int i = 0; i < nCount; i++)
  71. {
  72. m_pAddKeyPack->m_LicenseCombo.GetLBText(i,ProdDesc);
  73. m_LicenseCombo.AddString(ProdDesc);
  74. }
  75. m_LicenseCombo.SetCurSel(m_pAddKeyPack->m_LicenseCombo.GetCurSel());
  76. m_SpinCtrl.SetBase(10);
  77. m_SpinCtrl.SetRange(1,MAX_LICENSES);
  78. m_SpinCtrl.SetPos(1);
  79. OnSelchangeLicnesePack();
  80. return TRUE; // return TRUE unless you set the focus to a control
  81. // EXCEPTION: OCX Property Pages should return FALSE
  82. }
  83. void CRemoveLicenses::OnSelchangeLicnesePack()
  84. {
  85. // TODO: Add your control notification handler code here
  86. UpdateData();
  87. UINT uMaxLicenses = 0;
  88. //Get the Current Selection.
  89. int nSelection = m_LicenseCombo.GetCurSel( );
  90. //Get the Product Description.
  91. CString ProdDesc;
  92. m_LicenseCombo.GetLBText(nSelection,ProdDesc);
  93. //Search and pickup the keypack with this product description.
  94. //Set the Edit box to display the total licenses.
  95. POSITION pos = m_pAddKeyPack->m_pKeyPackList->GetHeadPosition();
  96. while(pos)
  97. {
  98. CKeyPack *pKeyPack = (CKeyPack *)m_pAddKeyPack->m_pKeyPackList->GetNext(pos);
  99. if(NULL == pKeyPack)
  100. break;
  101. LSKeyPack sKeyPack = pKeyPack->GetKeyPackStruct();
  102. if(0 == ProdDesc.CompareNoCase(sKeyPack.szProductDesc))
  103. {
  104. uMaxLicenses = sKeyPack.dwNumberOfLicenses;
  105. break;
  106. }
  107. }
  108. if(uMaxLicenses < MAX_LICENSES)
  109. {
  110. m_SpinCtrl.SetRange(1,uMaxLicenses);
  111. }
  112. else
  113. {
  114. m_SpinCtrl.SetRange(1,MAX_LICENSES);
  115. }
  116. GetDlgItem(IDOK)->EnableWindow(uMaxLicenses);
  117. GetDlgItem(IDC_NUM_LICENSES)->EnableWindow(uMaxLicenses);
  118. if(0 == uMaxLicenses)
  119. m_NumLicenses = 0;
  120. else
  121. m_NumLicenses = 1;
  122. UpdateData(FALSE);
  123. return;
  124. }
  125. void CRemoveLicenses::OnHelp()
  126. {
  127. // TODO: Add your control notification handler code here
  128. AfxGetApp()->WinHelp(IDC_HELP4,HELP_CONTEXT );
  129. }