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.

96 lines
2.5 KiB

  1. // Upgrades.cpp : implementation file
  2. //
  3. #include "precomp.hxx"
  4. #ifdef _DEBUG
  5. #define new DEBUG_NEW
  6. #undef THIS_FILE
  7. static char THIS_FILE[] = __FILE__;
  8. #endif
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CUpgrades dialog
  11. CUpgrades::CUpgrades(CWnd* pParent /*=NULL*/)
  12. : CDialog(CUpgrades::IDD, pParent)
  13. {
  14. //{{AFX_DATA_INIT(CUpgrades)
  15. // NOTE: the ClassWizard will add member initialization here
  16. //}}AFX_DATA_INIT
  17. }
  18. void CUpgrades::DoDataExchange(CDataExchange* pDX)
  19. {
  20. CDialog::DoDataExchange(pDX);
  21. //{{AFX_DATA_MAP(CUpgrades)
  22. // NOTE: the ClassWizard will add DDX and DDV calls here
  23. //}}AFX_DATA_MAP
  24. }
  25. BEGIN_MESSAGE_MAP(CUpgrades, CDialog)
  26. //{{AFX_MSG_MAP(CUpgrades)
  27. ON_BN_CLICKED(IDC_BUTTON1, OnAdd)
  28. ON_BN_CLICKED(IDC_BUTTON2, OnEdit)
  29. ON_BN_CLICKED(IDC_BUTTON3, OnRemove)
  30. //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CUpgrades message handlers
  34. void CUpgrades::OnAdd()
  35. {
  36. CListBox * pList = (CListBox *)GetDlgItem(IDC_LIST1);
  37. CAddUpgrade dlgAdd;
  38. dlgAdd.m_pUpgradeList = & m_UpgradeList;
  39. dlgAdd.m_pNameIndex = & m_NameIndex;
  40. // dlgAdd.m_pAppData = m_pAppData;
  41. if (IDOK == dlgAdd.DoModal())
  42. {
  43. // add the chosen app
  44. m_UpgradeList[dlgAdd.m_cookie] = dlgAdd.m_fUninstall;
  45. CString sz = (*m_pAppData)[dlgAdd.m_cookie].pDetails->pszPackageName;
  46. pList->AddString(sz);
  47. }
  48. }
  49. void CUpgrades::OnEdit()
  50. {
  51. // TODO: Add your control notification handler code here
  52. }
  53. void CUpgrades::OnRemove()
  54. {
  55. CListBox * pList = (CListBox *)GetDlgItem(IDC_LIST1);
  56. int iSel = pList->GetCurSel();
  57. if (iSel != LB_ERR)
  58. {
  59. CString sz;
  60. pList->GetText(iSel, sz);
  61. m_UpgradeList.erase(m_NameIndex[sz]);
  62. pList->DeleteString(iSel);
  63. }
  64. }
  65. BOOL CUpgrades::OnInitDialog()
  66. {
  67. // Walk the APPDATA map and build m_NameIndex.
  68. // UNDONE - also build the upgrade list by adding apps
  69. std::map<long, APP_DATA>::iterator i;
  70. for (i = m_pAppData->begin(); i != m_pAppData->end(); i++)
  71. {
  72. CString sz = i->second.pDetails->pszPackageName;
  73. m_NameIndex[sz] = i->first;
  74. }
  75. // UNDONE - pre-populate list box with the apps in the upgrade list
  76. CDialog::OnInitDialog();
  77. return TRUE; // return TRUE unless you set the focus to a control
  78. // EXCEPTION: OCX Property Pages should return FALSE
  79. }