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.

167 lines
4.7 KiB

  1. // LocPkg.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. // CLocPkg property page
  11. IMPLEMENT_DYNCREATE(CLocPkg, CPropertyPage)
  12. CLocPkg::CLocPkg() : CPropertyPage(CLocPkg::IDD)
  13. {
  14. //{{AFX_DATA_INIT(CLocPkg)
  15. m_fAlpha = FALSE;
  16. m_fX86 = FALSE;
  17. //}}AFX_DATA_INIT
  18. }
  19. CLocPkg::~CLocPkg()
  20. {
  21. *m_ppThis = NULL;
  22. }
  23. void CLocPkg::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CPropertyPage::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(CLocPkg)
  27. DDX_Check(pDX, IDC_CHECK1, m_fAlpha);
  28. DDX_Check(pDX, IDC_CHECK2, m_fX86);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(CLocPkg, CPropertyPage)
  32. //{{AFX_MSG_MAP(CLocPkg)
  33. ON_BN_CLICKED(IDC_CHECK1, OnChange)
  34. ON_BN_CLICKED(IDC_CHECK2, OnChange)
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CLocPkg message handlers
  39. BOOL CLocPkg::OnApply()
  40. {
  41. PLATFORMINFO * pPlatformInfo = m_pData->pDetails->pPlatformInfo;
  42. UINT i = 0;
  43. if (m_fX86)
  44. {
  45. i++;
  46. }
  47. if (m_fAlpha)
  48. {
  49. i++;
  50. }
  51. if (i == 0)
  52. {
  53. CString szTitle;
  54. szTitle.LoadString(IDS_BADDATA);
  55. CString szText;
  56. szText.LoadString(IDS_PLATFORMREQUIRED);
  57. MessageBox(szText, szTitle, MB_ICONEXCLAMATION | MB_OK);
  58. return FALSE;
  59. }
  60. m_pData->pDetails->pPlatformInfo = new PLATFORMINFO;
  61. m_pData->pDetails->pPlatformInfo->cPlatforms = i;
  62. m_pData->pDetails->pPlatformInfo->prgPlatform = new CSPLATFORM[i];
  63. m_pData->pDetails->pPlatformInfo->cLocales = pPlatformInfo->cLocales;
  64. m_pData->pDetails->pPlatformInfo->prgLocale = pPlatformInfo->prgLocale;
  65. i = 0;
  66. if (m_fX86)
  67. {
  68. m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwPlatformId = VER_PLATFORM_WIN32_NT;
  69. m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwVersionHi = 5;
  70. m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwVersionLo = 0;
  71. m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwProcessorArch = PROCESSOR_ARCHITECTURE_INTEL;
  72. i++;
  73. }
  74. if (m_fAlpha)
  75. {
  76. m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwPlatformId = VER_PLATFORM_WIN32_NT;
  77. m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwVersionHi = 5;
  78. m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwVersionLo = 0;
  79. m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwProcessorArch = PROCESSOR_ARCHITECTURE_ALPHA;
  80. }
  81. #if 0
  82. HRESULT hr = m_pIClassAdmin->UpgradePackage(m_pData->pDetails->pszPackageName,
  83. m_pData->pDetails);
  84. if (FAILED(hr))
  85. {
  86. PLATFORMINFO * pTemp = m_pData->pDetails->pPlatformInfo;
  87. m_pData->pDetails->pPlatformInfo = pPlatformInfo;
  88. pPlatformInfo = pTemp;
  89. }
  90. else
  91. MMCPropertyChangeNotify(m_hConsoleHandle, (long) m_cookie);
  92. #endif
  93. delete [] pPlatformInfo->prgPlatform;
  94. delete pPlatformInfo;
  95. return CPropertyPage::OnApply();
  96. }
  97. BOOL CLocPkg::OnInitDialog()
  98. {
  99. UINT i;
  100. for (i = m_pData->pDetails->pPlatformInfo->cPlatforms; i--;)
  101. {
  102. switch (m_pData->pDetails->pPlatformInfo->prgPlatform[i].dwProcessorArch)
  103. {
  104. case PROCESSOR_ARCHITECTURE_INTEL:
  105. m_fX86 = TRUE;
  106. break;
  107. case PROCESSOR_ARCHITECTURE_ALPHA:
  108. m_fAlpha = TRUE;
  109. break;
  110. default:
  111. break;
  112. }
  113. }
  114. TCHAR szBuffer[256];
  115. CString sz;
  116. i = 0;
  117. while (i < m_pData->pDetails->pPlatformInfo->cLocales)
  118. {
  119. GetLocaleInfo(m_pData->pDetails->pPlatformInfo->prgLocale[i], LOCALE_SLANGUAGE, szBuffer, 256);
  120. sz = szBuffer;
  121. GetLocaleInfo(m_pData->pDetails->pPlatformInfo->prgLocale[i], LOCALE_SCOUNTRY, szBuffer, 256);
  122. sz += _T(" - ");
  123. sz += szBuffer;
  124. i++;
  125. ((CListBox *)GetDlgItem(IDC_LIST1))->AddString(sz);
  126. }
  127. CPropertyPage::OnInitDialog();
  128. // unmarshal the IClassAdmin interface
  129. HRESULT hr = CoGetInterfaceAndReleaseStream(m_pIStream, IID_IClassAdmin, (void **) &m_pIClassAdmin);
  130. return TRUE; // return TRUE unless you set the focus to a control
  131. // EXCEPTION: OCX Property Pages should return FALSE
  132. }
  133. void CLocPkg::OnChange()
  134. {
  135. SetModified();
  136. }
  137. LRESULT CLocPkg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  138. {
  139. switch (message)
  140. {
  141. case WM_USER_REFRESH:
  142. // UNDONE
  143. return 0;
  144. case WM_USER_CLOSE:
  145. return GetOwner()->SendMessage(WM_CLOSE);
  146. default:
  147. return CPropertyPage::WindowProc(message, wParam, lParam);
  148. }
  149. }