Leaked source code of windows server 2003
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.

175 lines
5.2 KiB

  1. /******************************************************************************
  2. Source File: Profile Information Page.CPP
  3. This implements the class used to display the profile information page in the
  4. property page handler for the shell extension.
  5. Copyright (c) 1996 by Microsoft Corporation
  6. A Pretty Penny Enterprises Production
  7. Change History:
  8. 11-01-96 a-robkj@microsoft.com pieced this one together for the first time
  9. ******************************************************************************/
  10. #include "ICMUI.H"
  11. #include "Resource.H"
  12. static const TCHAR sacDefaultCMM[] = _TEXT("icm32.dll");
  13. // It looks like the way to make the icon draw is to subclass the Icon control
  14. // in the window. So, here's a Window Procedure for the subclass
  15. // CProfileInformationPage member functions
  16. // Class Constructor
  17. CProfileInformationPage::CProfileInformationPage(HINSTANCE hiWhere,
  18. LPCTSTR lpstrTarget) {
  19. m_pcpTarget = NULL;
  20. m_csProfile = lpstrTarget;
  21. m_psp.dwSize = sizeof m_psp;
  22. m_psp.dwFlags |= PSP_USETITLE;
  23. m_psp.hInstance = hiWhere;
  24. m_psp.pszTemplate = MAKEINTRESOURCE(ProfilePropertyPage);
  25. m_psp.pszTitle = MAKEINTRESOURCE(ProfilePropertyString);
  26. }
  27. // Class destructor
  28. CProfileInformationPage::~CProfileInformationPage() {
  29. if (m_pcpTarget) {
  30. delete m_pcpTarget;
  31. }
  32. }
  33. // Dialog box (property sheet) initialization
  34. BOOL CProfileInformationPage::OnInit() {
  35. m_pcpTarget = new CProfile(m_csProfile);
  36. if (m_pcpTarget) {
  37. // Retrieve the 'desc' key, and put it in the description field
  38. LPCSTR szDesc = m_pcpTarget->TagContents('desc', 4);
  39. if(szDesc)
  40. SetDlgItemTextA(m_hwnd, ProfileDescription, szDesc);
  41. // Get the copyright info from the 'cprt' tag
  42. LPCSTR szCprt = m_pcpTarget->TagContents('cprt');
  43. if(szCprt)
  44. SetDlgItemTextA(m_hwnd, ProfileProducerInfo, szCprt);
  45. // Get the profile info from the 'vued' tag, not 'K007' tag
  46. LPCSTR lpAdditionalInfo = m_pcpTarget->TagContents('vued',4);
  47. if (lpAdditionalInfo) {
  48. SetDlgItemTextA(m_hwnd, AdditionalProfileInfo, lpAdditionalInfo);
  49. } else {
  50. CString csNoAdditionalInfo;
  51. csNoAdditionalInfo.Load(NoAdditionalInfo);
  52. SetDlgItemTextA(m_hwnd, AdditionalProfileInfo, (LPCSTR)csNoAdditionalInfo);
  53. }
  54. // Set the CMM description and bitmap- these are supposed
  55. // to come from the CMM.
  56. // Get the CMM Name- this must be in char form
  57. union {
  58. char acCMM[5];
  59. DWORD dwCMM;
  60. };
  61. dwCMM = m_pcpTarget->GetCMM();
  62. acCMM[4] = '\0';
  63. // Use it to form a key into the ICM registry. If we find it, get
  64. // the CMM name. If we don't, then use the default CMM name (icm32)
  65. #ifdef UNICODE
  66. CString csKey =
  67. CString(_TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\ICM\\")) +
  68. (LPCTSTR) CString(acCMM);
  69. #else
  70. CString csKey =
  71. CString(_TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\ICM\\")) +
  72. (LPCTSTR) CString(acCMM);
  73. #endif
  74. HKEY hkCMM;
  75. if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE, csKey, &hkCMM)) {
  76. TCHAR acValue[MAX_PATH];
  77. dwCMM = MAX_PATH;
  78. if (ERROR_SUCCESS == RegEnumValue(hkCMM, 0, acValue, &dwCMM, NULL,
  79. NULL, NULL, NULL))
  80. csKey = acValue;
  81. else
  82. csKey = sacDefaultCMM;
  83. RegCloseKey(hkCMM);
  84. }
  85. else
  86. csKey = sacDefaultCMM;
  87. // See if we can get an instance handle for the DLL...
  88. HINSTANCE hi = LoadLibrary(csKey);
  89. if (!hi)
  90. return TRUE; // Nothing to do, here, let the defaults prevail.
  91. // Get description and icon identifier from CMS dll
  92. DWORD dwCMMIcon = 0, dwCMMDescription = 0;
  93. typedef BOOL (*FPCMGETINFO)(DWORD);
  94. FPCMGETINFO fpCMGetInfo;
  95. fpCMGetInfo = (FPCMGETINFO) GetProcAddress(hi,"CMGetInfo");
  96. if (fpCMGetInfo) {
  97. dwCMMIcon = (*fpCMGetInfo)(CMM_LOGOICON);
  98. dwCMMDescription = (*fpCMGetInfo)(CMM_DESCRIPTION);
  99. if (dwCMMDescription) {
  100. // Write the description, if there is one.
  101. csKey.Load(dwCMMDescription, hi);
  102. if ((LPCTSTR) csKey)
  103. SetDlgItemText(m_hwnd, CMMDescription, csKey);
  104. }
  105. if (dwCMMIcon) {
  106. // Change/Create the Icon, if there is one.
  107. HICON hiCMM = LoadIcon(hi, MAKEINTRESOURCE(dwCMMIcon));
  108. if (hiCMM)
  109. SendDlgItemMessage(m_hwnd, CMMIcon, STM_SETICON, (WPARAM) hiCMM, 0);
  110. }
  111. }
  112. return TRUE;
  113. } else {
  114. return FALSE;
  115. }
  116. }
  117. BOOL CProfileInformationPage::OnDestroy() {
  118. if (m_pcpTarget) {
  119. delete m_pcpTarget;
  120. m_pcpTarget = (CProfile *) NULL;
  121. }
  122. return FALSE; // still need to handle this message by def. proc.
  123. }