Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

profinfo.cpp

Go to the documentation of this file.
00001 /****************************************************************************** 00002 00003 Source File: Profile Information Page.CPP 00004 00005 This implements the class used to display the profile information page in the 00006 property page handler for the shell extension. 00007 00008 Copyright (c) 1996 by Microsoft Corporation 00009 00010 A Pretty Penny Enterprises Production 00011 00012 Change History: 00013 11-01-96 [email protected] pieced this one together for the first time 00014 00015 ******************************************************************************/ 00016 00017 #include "ICMUI.H" 00018 00019 #include "Resource.H" 00020 00021 static const TCHAR sacDefaultCMM[] = _TEXT("icm32.dll"); 00022 00023 // It looks like the way to make the icon draw is to subclass the Icon control 00024 // in the window. So, here's a Window Procedure for the subclass 00025 00026 // CProfileInformationPage member functions 00027 00028 // Class Constructor 00029 00030 CProfileInformationPage::CProfileInformationPage(HINSTANCE hiWhere, 00031 LPCTSTR lpstrTarget) { 00032 m_pcpTarget = NULL; 00033 m_csProfile = lpstrTarget; 00034 m_psp.dwSize = sizeof m_psp; 00035 m_psp.dwFlags |= PSP_USETITLE; 00036 m_psp.hInstance = hiWhere; 00037 m_psp.pszTemplate = MAKEINTRESOURCE(ProfilePropertyPage); 00038 m_psp.pszTitle = MAKEINTRESOURCE(ProfilePropertyString); 00039 } 00040 00041 // Class destructor 00042 00043 CProfileInformationPage::~CProfileInformationPage() { 00044 if (m_pcpTarget) { 00045 delete m_pcpTarget; 00046 } 00047 } 00048 00049 // Dialog box (property sheet) initialization 00050 00051 BOOL CProfileInformationPage::OnInit() { 00052 00053 m_pcpTarget = new CProfile(m_csProfile); 00054 00055 if (m_pcpTarget) { 00056 00057 // Retrieve the 'desc' key, and put it in the description field 00058 SetDlgItemTextA(m_hwnd, ProfileDescription, 00059 m_pcpTarget->TagContents('desc', 4)); 00060 00061 // Get the copyright info from the 'cprt' tag 00062 SetDlgItemTextA(m_hwnd, ProfileProducerInfo, 00063 m_pcpTarget->TagContents('cprt')); 00064 00065 // Get the profile info from the 'vued' tag, not 'K007' tag 00066 LPCSTR lpAdditionalInfo = m_pcpTarget->TagContents('vued',4); 00067 00068 if (lpAdditionalInfo) { 00069 SetDlgItemTextA(m_hwnd, AdditionalProfileInfo, lpAdditionalInfo); 00070 } else { 00071 CString csNoAdditionalInfo; 00072 csNoAdditionalInfo.Load(NoAdditionalInfo); 00073 SetDlgItemTextA(m_hwnd, AdditionalProfileInfo, (LPCSTR)csNoAdditionalInfo); 00074 } 00075 00076 // Set the CMM description and bitmap- these are supposed 00077 // to come from the CMM. 00078 00079 // Get the CMM Name- this must be in char form 00080 00081 union { 00082 char acCMM[5]; 00083 DWORD dwCMM; 00084 }; 00085 00086 dwCMM = m_pcpTarget->GetCMM(); 00087 acCMM[4] = '\0'; 00088 00089 // Use it to form a key into the ICM registry. If we find it, get 00090 // the CMM name. If we don't, then use the default CMM name (icm32) 00091 00092 #ifdef UNICODE 00093 CString csKey = 00094 CString(_TEXT("Software\\Microsoft\\Windows NT\\CurrentVersion\\ICM\\")) + 00095 (LPCTSTR) CString(acCMM); 00096 #else 00097 CString csKey = 00098 CString(_TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\ICM\\")) + 00099 (LPCTSTR) CString(acCMM); 00100 #endif 00101 00102 HKEY hkCMM; 00103 00104 if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE, csKey, &hkCMM)) { 00105 TCHAR acValue[MAX_PATH]; 00106 00107 dwCMM = MAX_PATH; 00108 00109 if (ERROR_SUCCESS == RegEnumValue(hkCMM, 0, acValue, &dwCMM, NULL, 00110 NULL, NULL, NULL)) 00111 csKey = acValue; 00112 else 00113 csKey = sacDefaultCMM; 00114 00115 RegCloseKey(hkCMM); 00116 } 00117 else 00118 csKey = sacDefaultCMM; 00119 00120 // See if we can get an instance handle for the DLL... 00121 00122 HINSTANCE hi = LoadLibrary(csKey); 00123 00124 if (!hi) 00125 return TRUE; // Nothing to do, here, let the defaults prevail. 00126 00127 // Get description and icon identifier from CMS dll 00128 00129 DWORD dwCMMIcon = 0, dwCMMDescription = 0; 00130 00131 typedef BOOL (*FPCMGETINFO)(DWORD); 00132 00133 FPCMGETINFO fpCMGetInfo; 00134 00135 fpCMGetInfo = (FPCMGETINFO) GetProcAddress(hi,"CMGetInfo"); 00136 00137 if (fpCMGetInfo) { 00138 00139 dwCMMIcon = (*fpCMGetInfo)(CMM_LOGOICON); 00140 dwCMMDescription = (*fpCMGetInfo)(CMM_DESCRIPTION); 00141 00142 if (dwCMMDescription) { 00143 // Write the description, if there is one. 00144 csKey.Load(dwCMMDescription, hi); 00145 if ((LPCTSTR) csKey) 00146 SetDlgItemText(m_hwnd, CMMDescription, csKey); 00147 } 00148 00149 if (dwCMMIcon) { 00150 // Change/Create the Icon, if there is one. 00151 HICON hiCMM = LoadIcon(hi, MAKEINTRESOURCE(dwCMMIcon)); 00152 if (hiCMM) 00153 SendDlgItemMessage(m_hwnd, CMMIcon, STM_SETICON, (WPARAM) hiCMM, 0); 00154 } 00155 } 00156 00157 return TRUE; 00158 } else { 00159 return FALSE; 00160 } 00161 } 00162 00163 BOOL CProfileInformationPage::OnDestroy() { 00164 00165 if (m_pcpTarget) { 00166 delete m_pcpTarget; 00167 m_pcpTarget = (CProfile *) NULL; 00168 } 00169 00170 return FALSE; // still need to handle this message by def. proc. 00171 } 00172 00173

Generated on Sat May 15 19:41:29 2004 for test by doxygen 1.3.7