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.

158 lines
4.1 KiB

  1. // pkgdtl.cpp : implementation file
  2. //
  3. #include "precomp.hxx"
  4. #include "fcntl.h"
  5. #include "io.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CPackageDetails property page
  13. IMPLEMENT_DYNCREATE(CPackageDetails, CPropertyPage)
  14. CPackageDetails::CPackageDetails() : CPropertyPage(CPackageDetails::IDD)
  15. {
  16. //{{AFX_DATA_INIT(CPackageDetails)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. m_hConsoleHandle = NULL;
  20. }
  21. CPackageDetails::~CPackageDetails()
  22. {
  23. }
  24. void CPackageDetails::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CPropertyPage::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CPackageDetails)
  28. DDX_Control(pDX, IDC_LIST1, m_cList);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(CPackageDetails, CPropertyPage)
  32. //{{AFX_MSG_MAP(CPackageDetails)
  33. ON_WM_DESTROY()
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CPackageDetails message handlers
  38. void CPackageDetails::OnDestroy()
  39. {
  40. MMCFreeNotifyHandle(m_hConsoleHandle);
  41. CPropertyPage::OnDestroy();
  42. // Delete the CPackageDetails object
  43. delete this;
  44. }
  45. // removes tabs and \n characters
  46. void Convert(WCHAR * wsz, CString &sz)
  47. {
  48. sz="";
  49. int iIn=0;
  50. int iOut=0;
  51. WCHAR ch;
  52. while (ch = wsz[iIn++])
  53. {
  54. switch (ch)
  55. {
  56. case L'\t':
  57. iOut++;
  58. sz += ' ';
  59. while (iOut % 4)
  60. {
  61. iOut++;
  62. sz += ' ';
  63. }
  64. break;
  65. case L'\n':
  66. break;
  67. default:
  68. iOut++;
  69. sz += ch;
  70. break;
  71. }
  72. }
  73. }
  74. BOOL CPackageDetails::OnInitDialog()
  75. {
  76. CPropertyPage::OnInitDialog();
  77. m_cList.ResetContent();
  78. HRESULT hr = CoGetInterfaceAndReleaseStream(m_pIStream, IID_IClassAdmin, (void **) &m_pIClassAdmin);
  79. if (SUCCEEDED(hr))
  80. {
  81. // compute the number of CLASSDETAIL elements that
  82. // need to be fetched
  83. ULONG cCD = 0;
  84. ULONG nApp;
  85. for (nApp = 0; nApp < m_pData->pDetails->cApps; nApp++)
  86. {
  87. cCD += m_pData->pDetails->pAppDetail[nApp].cClasses;
  88. }
  89. // allocate them and fetch the list
  90. CLASSDETAIL * rgCD = new CLASSDETAIL[cCD];
  91. CLASSDETAIL * rgClassDetail = rgCD;
  92. // BUGBUG - put error checking in here!
  93. for (nApp = 0; nApp < m_pData->pDetails->cApps; nApp++)
  94. {
  95. ULONG nClass;
  96. for (nClass = 0; nClass < m_pData->pDetails->pAppDetail[nApp].cClasses; nClass++)
  97. {
  98. hr = m_pIClassAdmin->GetClassDetails(m_pData->pDetails->pAppDetail[nApp].prgClsIdList[nClass], rgCD);
  99. // advance to next CLASSDETAIL structure
  100. rgCD++;
  101. }
  102. }
  103. FILE * stream = tmpfile();
  104. _setmode(_fileno(stream), _O_TEXT);
  105. if (m_pData->pDetails)
  106. {
  107. DumpOnePackage(stream,
  108. m_pData->pDetails,
  109. rgClassDetail);
  110. }
  111. rewind(stream);
  112. WCHAR wsz[256];
  113. CString szTemp;
  114. int cWidth = 0;
  115. m_cList.ResetContent();
  116. while (fgetws(wsz, 256, stream))
  117. {
  118. Convert(wsz, szTemp);
  119. CSize csExtent = m_cList.GetDC()->GetTextExtent(szTemp);
  120. m_cList.GetDC()->LPtoDP(&csExtent);
  121. if (cWidth < csExtent.cx)
  122. {
  123. cWidth = csExtent.cx;
  124. }
  125. m_cList.AddString(szTemp);
  126. }
  127. m_cList.SetHorizontalExtent(cWidth);
  128. fclose(stream);
  129. }
  130. return TRUE; // return TRUE unless you set the focus to a control
  131. // EXCEPTION: OCX Property Pages should return FALSE
  132. }