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.

4981 lines
140 KiB

  1. // INFWizrd.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "minidev.h"
  5. #include <gpdparse.h>
  6. #include "rcfile.h"
  7. #include "projrec.h"
  8. #include "projview.h"
  9. #include "comctrls.h"
  10. #include "Gpdview.h" //RAID 0001
  11. #include "INFWizrd.h"
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CINFWizard
  19. IMPLEMENT_DYNAMIC(CINFWizard, CPropertySheet)
  20. CINFWizard::CINFWizard(CWnd* pParentWnd, UINT iSelectPage)
  21. : CPropertySheet(IDS_INFWizTitle, pParentWnd ) //iSelectPage ) RAID 0001//Welcome page should be top even iselectpage=1
  22. {
  23. // Save parent pointer
  24. m_pcpvParent = (CProjectView*) pParentWnd ;
  25. // Give the pages a pointer to the sheet.
  26. m_ciww.m_pciwParent = this ;
  27. m_ciwm.m_pciwParent = this ;
  28. m_ciwgpi.m_pciwParent = this ;
  29. m_ciwbd.m_pciwParent = this ;
  30. m_ciwip.m_pciwParent = this ;
  31. m_ciwif.m_pciwParent = this ;
  32. m_ciwis.m_pciwParent = this ;
  33. m_ciwds.m_pciwParent = this ;
  34. m_ciwef.m_pciwParent = this ;
  35. m_ciwmn.m_pciwParent = this ;
  36. m_ciwnse.m_pciwParent = this ;
  37. m_ciwnsms.m_pciwParent = this ;
  38. m_ciws.m_pciwParent = this ;
  39. // Add the wizard's pages and set wizard moede.
  40. AddPage(&m_ciww) ;
  41. AddPage(&m_ciwm) ;
  42. AddPage(&m_ciwgpi) ;
  43. AddPage(&m_ciwbd) ;
  44. AddPage(&m_ciwip) ;
  45. AddPage(&m_ciwif) ;
  46. AddPage(&m_ciwis) ;
  47. AddPage(&m_ciwds) ;
  48. AddPage(&m_ciwef) ;
  49. AddPage(&m_ciwmn) ;
  50. AddPage(&m_ciwnse) ;
  51. AddPage(&m_ciwnsms) ;
  52. AddPage(&m_ciws) ;
  53. SetWizardMode() ;
  54. // Get and save a pointer to the project record (document) class associated
  55. // with this class' parent.
  56. if(NULL != iSelectPage ){ //RAID 0001
  57. CGPDViewer* pcgv = (CGPDViewer*) m_pcpvParent;
  58. m_pcgc = pcgv ->GetDocument();
  59. }
  60. else{ // END RAID
  61. m_pcpr = (CProjectRecord*) m_pcpvParent->GetDocument() ;
  62. m_pcgc = NULL;
  63. }
  64. }
  65. CINFWizard::~CINFWizard()
  66. {
  67. }
  68. unsigned CINFWizard::GetModelCount()
  69. {
  70. if(m_pcgc) //RAID 0001
  71. return 1; // only one gpdviewer
  72. else //END RAID
  73. return m_pcpr->ModelCount() ;
  74. }
  75. CModelData& CINFWizard::GetModel(unsigned uidx)
  76. {
  77. return m_pcpr->Model(uidx) ;
  78. }
  79. void CINFWizard::SetFixupFlags()
  80. {
  81. // Set flags in each of the pages that need to update their data and UI when
  82. // the selected models change.
  83. m_ciwgpi.m_bSelChanged = true ;
  84. m_ciwbd.m_bSelChanged = true ;
  85. m_ciwip.m_bSelChanged = true ;
  86. m_ciwif.m_bSelChanged = true ;
  87. m_ciwis.m_bSelChanged = true ;
  88. m_ciwds.m_bSelChanged = true ;
  89. m_ciwef.m_bSelChanged = true ;
  90. m_ciwnsms.m_bSelChanged = true ;
  91. }
  92. void CINFWizard::BiDiDataChanged()
  93. {
  94. // If the selected models' BiDi data may have changed, call the pages that
  95. // maintain related data so that they can update their data when/if needed.
  96. m_ciwis.BiDiDataChanged() ;
  97. m_ciwds.BiDiDataChanged() ;
  98. }
  99. void CINFWizard::NonStdSecsChanged()
  100. {
  101. // If the nonstandard sections may have changed, call the pages that
  102. // maintain related data so that they can update their data when/if needed.
  103. m_ciwnsms.NonStdSecsChanged() ;
  104. }
  105. bool CINFWizard::GenerateINFFile()
  106. {
  107. // This might take a while, so...
  108. CWaitCursor cwc ;
  109. // Mark all of the sections in the "section used in INF file flags" array
  110. // as NOT having been used.
  111. unsigned unumelts = (unsigned)m_ciwnse.m_cuaSecUsed.GetSize() ;
  112. for (unsigned u = 0 ; u < unumelts ; u++)
  113. m_ciwnse.m_cuaSecUsed[u] = false ;
  114. // Initialize the source disk files array.
  115. m_csaSrcDskFiles.RemoveAll() ;
  116. // Start by loading the string with the INF's opening comment header.
  117. m_csINFContents.LoadString(IDS_INFText_HeaderCmt) ;
  118. // Add the version section with the appropriate value for the provider.
  119. CString cs ;
  120. cs.Format(IDS_INFText_Version, m_ciwmn.m_csMfgAbbrev) ;
  121. ChkForNonStdAdditions(cs, _T("Version")) ;
  122. m_csINFContents += cs ;
  123. // Add the ClassInstall32.NT and printer_class_addreg sections plus the
  124. // comments for the manufacturer's section.
  125. cs.LoadString(IDS_INFText_ClInst32) ;
  126. ChkForNonStdAdditions(cs, _T("ClassInstall32.NT")) ;
  127. m_csINFContents += cs ;
  128. cs.LoadString(IDS_INFText_PCAddr) ;
  129. ChkForNonStdAdditions(cs, _T("printer_class_addreg")) ;
  130. m_csINFContents += cs ;
  131. cs.LoadString(IDS_INFText_MfgCmt) ;
  132. m_csINFContents += cs ;
  133. // Add the manufacturer's name to the manufacturer's section and add the
  134. // section.
  135. cs.Format(IDS_INFText_Manufacturer, m_ciwmn.m_csMfgName) ;
  136. ChkForNonStdAdditions(cs, _T("Manufacturer")) ;
  137. m_csINFContents += cs ;
  138. // Build the model specifications section and add the section.
  139. BldModSpecSec(m_csINFContents) ;
  140. // Build the copy file sections and add them to the INF contents.
  141. BuildInstallAndCopySecs(m_csINFContents) ;
  142. // Add the DestinationDirs section to the INF contents.
  143. cs.LoadString(IDS_INFText_DestDirs) ;
  144. AddICMFilesToDestDirs(cs) ;
  145. ChkForNonStdAdditions(cs, _T("DestinationDirs")) ;
  146. m_csINFContents += cs ;
  147. // Add the SourceDisksNames sections to the INF contents. Each section will
  148. // include the Provider string.
  149. cs.LoadString(IDS_INFText_SrcDiskNamesI) ;
  150. ChkForNonStdAdditions(cs, _T("SourceDisksNames.x86")) ;
  151. m_csINFContents += cs ;
  152. // Add the SourceDisksFiles sections to the INF contents.
  153. AddSourceDisksFilesSec(m_csINFContents) ;
  154. // Add the nonstandard sections to the INF contents.
  155. AddNonStandardSecs(m_csINFContents) ;
  156. // Finish up by adding the Strings section to the INF contents.
  157. cs.LoadString(IDS_INFText_Strings) ;
  158. cs.Format(IDS_INFText_Strings, m_ciwmn.m_csMfgAbbrev, m_ciwmn.m_csMfgName,
  159. m_ciwmn.m_csMfgName) ;
  160. ChkForNonStdAdditions(cs, _T("Strings")) ;
  161. m_csINFContents += cs ;
  162. m_csaSrcDskFiles.RemoveAll() ; // Array not needed anymore
  163. // All went well so...
  164. return true ;
  165. }
  166. void CINFWizard::AddSourceDisksFilesSec(CString& csinf)
  167. {
  168. // Begin the section with the section header.
  169. CString cs, cs2, csentry ;
  170. cs.LoadString(IDS_INFTextSrcDiskFilesHdr) ;
  171. // Remove any duplicate entries from source disk files array.
  172. int n, n2 ;
  173. for (n = 0 ; n < m_csaSrcDskFiles.GetSize() ; n++)
  174. for (n2 = n + 1 ; n2 < m_csaSrcDskFiles.GetSize() ; )
  175. if (m_csaSrcDskFiles[n] == m_csaSrcDskFiles[n2])
  176. m_csaSrcDskFiles.RemoveAt(n2) ;
  177. else
  178. n2++ ;
  179. // Get a count of the number of files in the source disk files array.
  180. unsigned unumelts = (unsigned)m_csaSrcDskFiles.GetSize() ;
  181. // Add an entry for each file in the array.
  182. for (unsigned u = 0 ; u < unumelts ; u++) {
  183. // Quote the file name if needed.
  184. cs2 = m_csaSrcDskFiles[u] ;
  185. //if (cs2[0] != _T('\"'))
  186. // QuoteFile(cs2) ;
  187. // Use the model's file name to build the entry for this model. Then
  188. // add this entry to the section.
  189. csentry.Format(IDS_INFText_SrcDiskFilesEntry, cs2) ;
  190. cs += csentry ;
  191. } ;
  192. // Add any extra entries there might be for this section and then add the
  193. // section to the INF contents.
  194. ChkForNonStdAdditions(cs, _T("SourceDisksFiles")) ;
  195. csinf += cs ;
  196. }
  197. void CINFWizard::ChkForNonStdAdditions(CString& cs, LPCTSTR strsection)
  198. {
  199. // Try to find the section amongst the list of sections with nonstandard
  200. // additions.
  201. CStringArray& csasections = m_ciwnse.m_csaSections ;
  202. CString cssechdr ;
  203. cssechdr = csLBrack + strsection + csRBrack ;
  204. unsigned unumelts = (unsigned)csasections.GetSize() ;
  205. for (unsigned u = 0 ; u < unumelts ; u++) {
  206. if (csasections[u].CompareNoCase(cssechdr) == 0)
  207. break ;
  208. } ;
  209. // If the section was found, mark the section as used and add the entries
  210. // for the section to the string.
  211. //
  212. // DEAD_BUG - Sometimes, the user may have entered replacement entries for
  213. // standard ones. This isn't handled correctly. :
  214. // S.G : check the same keyword between cs and m_ciwnse exist, and replace cs keywod
  215. // with that of m_ciwnse // raid 71332
  216. unsigned unSize = 0 ;
  217. if (u < unumelts ) {
  218. CStringArray* pcsa ;
  219. pcsa = (CStringArray*) m_ciwnse.m_coaSectionArrays[u] ;
  220. unSize = (unsigned)pcsa->GetSize() ;
  221. } ;
  222. if ( unSize ) {
  223. m_ciwnse.m_cuaSecUsed[u] = true ;
  224. CStringArray* pcsa ;
  225. pcsa = (CStringArray*) m_ciwnse.m_coaSectionArrays[u] ;
  226. unumelts = (unsigned)pcsa->GetSize() ;
  227. CUIntArray cuia ;
  228. cuia.SetSize(10) ;
  229. CStringArray csaNewcs;
  230. int ulen = csCRLF.GetLength() ; // just in case, unicode : what is the length of "\r\n".
  231. unsigned i , k ,utelen ;
  232. i = k = utelen = 0 ;
  233. while (-1 != (i = cs.Find(csCRLF, i + 1) ) ) {
  234. utelen = i - k ;
  235. csaNewcs.Add(cs.Mid(k,utelen + ulen) ); // we have to cut the string between csCR and csCR
  236. k = i + ulen;
  237. } ;
  238. for (i = 0 ; i < unSize ; i++ )
  239. cuia[i] = true;
  240. for (i = 1; i < (unsigned)csaNewcs.GetSize() ; i++ ) {
  241. CString cstmp = csaNewcs.GetAt(i);
  242. cstmp = cstmp.Left(cstmp.Find(_T("=")) + 1) ;
  243. if (! cstmp.CompareNoCase(_T("")) )
  244. break;
  245. for (u = 0 ; u < unSize ; u++) {
  246. CString csKeyw = pcsa->GetAt(u) ;
  247. CString csComp = csKeyw.Left(csKeyw.Find(_T("=")) + 1) ;
  248. if(! cstmp.CompareNoCase (csComp) ) {
  249. csKeyw += csCRLF ;
  250. csaNewcs.SetAt(i,csKeyw) ;
  251. cuia[u] = false;
  252. } ;
  253. } ;
  254. } ;
  255. for ( u = 0 ; u < unSize ; u ++ )
  256. if (cuia[u] ) {
  257. CString csAdd = pcsa->GetAt(u) ;
  258. csAdd += csCRLF ;
  259. csaNewcs.Add(csAdd) ;
  260. } ;
  261. CString csnew ;
  262. for ( u = 0 ; u < (unsigned)csaNewcs.GetSize(); u ++ )
  263. csnew += csaNewcs.GetAt(u);
  264. cs = csnew ;
  265. } ;
  266. // Add an extra line to this section's strings to separate it from the
  267. // next one.
  268. cs += csCRLF ;
  269. }
  270. void CINFWizard::AddNonStandardSecs(CString& csinf)
  271. {
  272. CString cs ;
  273. // Loop through each nonstandard section.
  274. CStringArray& csasections = m_ciwnse.m_csaSections ;
  275. unsigned unumelts = (unsigned)csasections.GetSize() ;
  276. CStringArray* pcsa ;
  277. unsigned u2, unumstrs ;
  278. for (unsigned u = 0 ; u < unumelts ; u++) {
  279. // Skip this section if it is not a nonstandard section. IE, its
  280. // entries have already been added to one of the standard sections.
  281. if (m_ciwnse.m_cuaSecUsed[u])
  282. continue ;
  283. // Skip this section if it is the Strings section. It will be added
  284. // later.
  285. if (csasections[u].CompareNoCase(_T("[Strings]")) == 0)
  286. continue ;
  287. // Get info about the section's entries. Skip the section if it has
  288. // no entries.
  289. pcsa = (CStringArray*) m_ciwnse.m_coaSectionArrays[u] ;
  290. unumstrs = (unsigned)pcsa->GetSize() ;
  291. if (unumstrs == 0)
  292. continue ;
  293. // Start the section with its header.
  294. cs = csasections[u] + csCRLF ;
  295. // Add each of the entries to the section.
  296. for (u2 = 0 ; u2 < unumstrs ; u2++)
  297. cs += pcsa->GetAt(u2) + csCRLF ;
  298. cs += csCRLF ;
  299. // Add the section to the INF contents
  300. csinf += cs ;
  301. } ;
  302. }
  303. void CINFWizard::BldModSpecSec(CString& csinf)
  304. {
  305. // Add the comment for this section to the INF file
  306. CString cs, csl, csr, csfn, csmodel, cspnpid ;
  307. cs.LoadString(IDS_INFText_ModCmt) ;
  308. csinf += cs ;
  309. // Build the section header
  310. cs = csLBrack + m_ciwmn.m_csMfgName + csRBrack + csCRLF ;
  311. // Build the entry for each model and add them to the section. The format
  312. // is:
  313. // "model name" = filename,PnP ID,model_name
  314. CStringArray& csamodels = GetINFModels() ;
  315. int nummodels = (int)csamodels.GetSize() ;
  316. int n, npos, nlen ;
  317. for (n = 0 ; n < nummodels ; n++) {
  318. csmodel = csamodels[n] ;
  319. csmodel.TrimLeft() ;
  320. csmodel.TrimRight() ;
  321. // If the user supplied a real PnP ID, it is used. If not, a pseudo
  322. // PnP ID is generated.
  323. if (!m_ciwgpi.m_csaModelIDs[n].IsEmpty())
  324. cspnpid = m_ciwgpi.m_csaModelIDs[n] ;
  325. else {
  326. CCompatID ccid(m_ciwmn.m_csMfgName, csmodel) ;
  327. ccid.GenerateID(cspnpid) ;
  328. } ;
  329. nlen = csmodel.GetLength() ;
  330. while ((npos = csmodel.Find(_T(" "))) != -1) {
  331. csl = (npos > 0) ? csmodel.Left(npos) : csEmpty ;
  332. csr = (npos + 1 < nlen) ? csmodel.Right(nlen - npos - 1) : csEmpty ;
  333. csmodel = csl + _T("_") + csr ;
  334. } ;
  335. csfn = GetModelFile(csamodels[n]) ;
  336. //QuoteFile(csfn) ;
  337. cs += csQuote + csamodels[n] + csQuote + csEq + csfn + csComma
  338. + cspnpid + csComma + csmodel + csCRLF ;
  339. } ;
  340. // Add non standard additions and then add the section to the INF file contents
  341. ChkForNonStdAdditions(cs, m_ciwmn.m_csMfgName) ;
  342. csinf += cs ;
  343. }
  344. void CINFWizard::BuildInstallAndCopySecs(CString& csinf)
  345. {
  346. // Add the comment for the Install sections to the INF contents
  347. CString cs ;
  348. cs.LoadString(IDS_INFText_InstallCmt) ;
  349. csinf += cs ;
  350. // Load the section components that will be needed repeatedly
  351. CString cskey, csdrvdll ;
  352. cskey.LoadString(IDS_INFText_CopyKey) ;
  353. bool bbidiadded = false ; // True iff BiDi DLL in [SourceDiskFiles] array
  354. // Create an install section for each model and add it the INF contents
  355. CStringArray& csamodels = GetINFModels() ;
  356. CStringArray csagpdfile ;
  357. CString csmodelfile, cshdr, csinc(_T("*Include:")), cstmp ;
  358. int numstrs, nloc ;
  359. unsigned unummodels = (unsigned)csamodels.GetSize() ;
  360. for (unsigned u = 0 ; u < unummodels ; u++) {
  361. // Build the section header
  362. cshdr = csmodelfile = GetModelFile(csamodels[u]) ;
  363. cs = csLBrack + csmodelfile + csRBrack + csCRLF ;
  364. // Read the GPD to get the DLL name & add it to SourceDiskFiles array.
  365. if (!ReadGPDAndGetDLLName(csdrvdll,csamodels[u],csagpdfile,csmodelfile))
  366. continue ;
  367. // Build the copy files statement. Begin by adding the copy files
  368. // entry, the DLL, and the GPD to the statement.
  369. //QuoteFile(csmodelfile) ;
  370. cs += cskey + csdrvdll + csComma + csAtSign + csmodelfile ;
  371. m_csaSrcDskFiles.Add(csmodelfile) ; // Add to [SourceDiskFiles] array
  372. // Add ICM files to the copy files entry when needed.
  373. AddFileList(cs, (CStringArray*) m_ciwip.m_coaProfileArrays[u]) ;
  374. // Add the nonstandard files for this model to the copy files entry
  375. // when needed.
  376. AddFileList(cs, (CStringArray*) m_ciwef.m_coaExtraFSArrays[u]) ;
  377. // Scan the current model's GPD file for include statements.
  378. // If any are found, add them to the copy files entry.
  379. numstrs = (int) csagpdfile.GetSize() ;
  380. for (int n = 0 ; n < numstrs ; n++) {
  381. if ((nloc = csagpdfile[n].Find(csinc)) == -1)
  382. continue ;
  383. cstmp = csagpdfile[n].Mid(nloc + csinc.GetLength()) ;
  384. cstmp.TrimLeft() ;
  385. cstmp.TrimRight() ;
  386. if (cstmp[0] == csQuote[0]) // Remove quotes
  387. cstmp = cstmp.Mid(1, cstmp.GetLength() - 2) ;
  388. if ((nloc = cstmp.ReverseFind(_T('\\'))) > -1) // Remove path
  389. cstmp = cstmp.Right(cstmp.GetLength() - nloc - 1) ;
  390. if (cstmp.CompareNoCase(_T("stdnames.gpd")) == 0)
  391. continue ; // File include below
  392. //QuoteFile(cstmp) ;
  393. m_csaSrcDskFiles.Add(cstmp) ; // Add to [SourceDiskFiles] array
  394. cs += csComma + csAtSign + cstmp ;
  395. } ;
  396. // Add any required nonstandard sections to the model's CopyFiles stmt.
  397. AddNonStdSectionsForModel(cs, (int) u, csamodels[u]) ;
  398. // Add the data sections statement to the Installs section
  399. AddDataSectionStmt(cs, (int) u) ;
  400. // Add the data file statement to the Install section
  401. cstmp.Format(IDS_INFText_DataFileKey, csmodelfile) ;
  402. cs += cstmp ;
  403. // Add the Include and Needs statements to the Install section
  404. AddIncludeNeedsStmts(cs, (int) u) ;
  405. // Add the section to the INF contents.
  406. //cs += csCRLF ;
  407. ChkForNonStdAdditions(cs, cshdr) ;
  408. csinf += cs ;
  409. } ;
  410. }
  411. bool CINFWizard::ReadGPDAndGetDLLName(CString& csdrvdll, CString& csmodel,
  412. CStringArray& csagpdfile,
  413. CString& csmodelfile)
  414. {
  415. // Load the GPD file. Complain and return false if this fails.
  416. CString cserr ;
  417. if (!LoadFile(GetModelFile(csmodel, true), csagpdfile)) {
  418. cserr.Format(IDS_INFGPDReadError, csmodelfile) ;
  419. AfxMessageBox(cserr, MB_ICONEXCLAMATION) ;
  420. return false ;
  421. } ;
  422. // Get the number of lines in the file and the DLL keyword.
  423. int nloc ;
  424. int numstrs = (int) csagpdfile.GetSize() ;
  425. CString csdllkey(_T("*ResourceDLL:")) ;
  426. // Look for the DLL name in the GPD file.
  427. for (int n = 0 ; n < numstrs ; n++) {
  428. // Continue if current line doesn't contain DLL file name.
  429. if ((nloc = csagpdfile[n].Find(csdllkey)) == -1)
  430. continue ;
  431. // Isolate the DLL file name in the current statement.
  432. csdrvdll = csagpdfile[n].Mid(nloc + csdllkey.GetLength()) ;
  433. csdrvdll.TrimLeft() ;
  434. csdrvdll.TrimRight() ;
  435. if (csdrvdll[0] == csQuote[0]) // Remove quotes
  436. csdrvdll = csdrvdll.Mid(1, csdrvdll.GetLength() - 2) ;
  437. if ((nloc = csdrvdll.ReverseFind(_T('\\'))) > -1) // Remove path
  438. csdrvdll = csdrvdll.Right(csdrvdll.GetLength() - nloc - 1) ;
  439. // Add the DLL file name to the SourceDiskFiles array and then add an
  440. // atsign to it so that it will be ready for future use.
  441. m_csaSrcDskFiles.Add(csdrvdll) ;
  442. csdrvdll = csAtSign + csdrvdll ;
  443. return true ;
  444. } ;
  445. // If this point is reached, the DLL file name could not be found so
  446. // complain and return false.
  447. cserr.Format(IDS_INFNoDLLError, csmodelfile) ;
  448. AfxMessageBox(cserr, MB_ICONEXCLAMATION) ;
  449. return false ;
  450. }
  451. void CINFWizard::AddFileList(CString& cssection, CStringArray* pcsa)
  452. {
  453. int n, numstrs, npos ;
  454. // If there is a list of files to add to the section...
  455. if ((numstrs = (int)pcsa->GetSize()) > 0) {
  456. // ... Add each file to the section
  457. CString cstmp ;
  458. for (n = 0 ; n < numstrs ; n++) {
  459. cstmp = pcsa->GetAt(n) ;
  460. // If the filespec contains a path, remove it.
  461. if ((npos = cstmp.ReverseFind(_T('\\'))) > -1)
  462. cstmp = cstmp.Right(cstmp.GetLength() - npos - 1) ;
  463. // Quote the file name if it contains space(s).
  464. //QuoteFile(cstmp) ;
  465. m_csaSrcDskFiles.Add(cstmp) ; // Add to [SourceDiskFiles] array
  466. // Add this file to the section.
  467. cssection += csComma + csAtSign + cstmp ;
  468. } ;
  469. } ;
  470. }
  471. void CINFWizard::AddICMFilesToDestDirs(CString& cssection)
  472. {
  473. int n, n2, numstrs, npos, numarrays ;
  474. CStringArray* pcsa ;
  475. CString cstmp, cstmp2 ;
  476. // Find out how many ICM file, string arrays there are.
  477. numarrays = (int) m_ciwip.m_coaProfileArrays.GetSize() ;
  478. // Check each array for ICM filespecs...
  479. for (n = 0 ; n < numarrays ; n++) {
  480. // Find out how many strings are in the current array
  481. pcsa = (CStringArray*) m_ciwip.m_coaProfileArrays[n] ;
  482. numstrs = (int) pcsa->GetSize() ;
  483. // Add each string in the current array to the DestinationDirs section.
  484. for (n2 = 0 ; n2 < numstrs ; n2++) {
  485. cstmp = pcsa->GetAt(n2) ;
  486. // If the filespec contains a path, remove it.
  487. if ((npos = cstmp.ReverseFind(_T('\\'))) > -1)
  488. cstmp = cstmp.Right(cstmp.GetLength() - npos - 1) ;
  489. // Format the statement for this file and add it to the section.
  490. cstmp2.Format(IDS_INFText_ICMDest,cstmp) ;
  491. cssection += cstmp2 ;
  492. } ;
  493. } ;
  494. }
  495. CString CINFWizard::GetModelFile(CString& csmodel, bool bfspec/*=false*/)
  496. {
  497. // Find the class instance associated with the specified model.
  498. //RAID 0001
  499. if(m_pcgc){
  500. CString csFileName = m_pcgc->ModelData()->GetKeywordValue(m_pcgc->
  501. GetPathName(),_T("GPDFileName"));
  502. if (bfspec)
  503. return m_pcgc->GetPathName() ;
  504. else
  505. return csFileName;
  506. }
  507. else
  508. {
  509. //END 0001
  510. unsigned unummodels = GetModelCount() ;
  511. for (unsigned u = 0 ; u < unummodels ; u++) {
  512. if (csmodel == GetModel(u).Name())
  513. break ;
  514. } ;
  515. ASSERT(u < unummodels) ;
  516. // Either return a full filespec or just a file name.
  517. if (bfspec)
  518. return (GetModel(u).FileName()) ;
  519. else
  520. return (GetModel(u).FileTitleExt()) ;
  521. } // else{ END RAID 0001
  522. }
  523. void CINFWizard::AddDataSectionStmt(CString& csinst, int nmod)
  524. {
  525. // Prepare to determine the contents of the data section statement.
  526. CString cs, cs2 ;
  527. cs2 = csEmpty ;
  528. int nid = IDS_DataSecUni ;
  529. CUIntArray* pcuia = (CUIntArray*) m_ciwds.m_coaStdDataSecs[nmod] ;
  530. // Find the only one - if any - of the first three data section names that
  531. // can be added to the statement.
  532. for (int n = 0 ; n < NUMDATASECFLAGS - 1 ; n++, nid++)
  533. if ((*pcuia)[n]) {
  534. cs2.LoadString(nid) ;
  535. break ;
  536. } ;
  537. // If there is a nonstandard data section, add it too.
  538. if ((*pcuia)[IDF_OTHER]) {
  539. if (!cs2.IsEmpty())
  540. cs2 += csComma ;
  541. cs2 += m_ciwds.m_csaOtherDataSecs[nmod] ;
  542. } ;
  543. // Finish formating the data section statement and add it to the rest of
  544. // the install section.
  545. cs.Format(IDS_INFText_DataSecKey, cs2) ;
  546. csinst += cs ;
  547. }
  548. void CINFWizard::AddIncludeNeedsStmts(CString& csinst, int nmod)
  549. {
  550. CString cs, cs2 ;
  551. // Build the Include statement and add it to the section..
  552. cs.Format(IDS_INFText_IncludeKey, m_ciwif.m_csaIncFiles[nmod]) ;
  553. csinst += cs ;
  554. // Prepare to determine the contents of the needs section statement.
  555. cs2 = csEmpty ;
  556. CUIntArray* pcuia = (CUIntArray*) m_ciwis.m_coaStdInstSecs[nmod] ;
  557. // The TrueType section, if needed, is the first section to list in the
  558. // Includes statement.
  559. if ((*pcuia)[ISF_TTF])
  560. cs2.LoadString(IDS_InstSecTtf) ;
  561. // Find the only one - if any - of the first three install section names
  562. // that can be added to the statement.
  563. int nid = IDS_InstSecUni ;
  564. for (int n = 0 ; n < NUMINSTSECFLAGS - 2 ; n++, nid++)
  565. if ((*pcuia)[n]) {
  566. if (!cs2.IsEmpty())
  567. cs2 += csComma ;
  568. cs.LoadString(nid) ;
  569. cs2 += cs ;
  570. break ;
  571. } ;
  572. // If there is a nonstandard install section, add it too.
  573. if ((*pcuia)[ISF_OTHER]) {
  574. if (!cs2.IsEmpty())
  575. cs2 += csComma ;
  576. cs2 += m_ciwis.m_csaOtherInstSecs[nmod] ;
  577. } ;
  578. // Finish formating the install section statement and add it to the rest of
  579. // the install section.
  580. cs.Format(IDS_INFText_NeedsKey, cs2) ;
  581. csinst += cs ;
  582. }
  583. void CINFWizard::AddNonStdSectionsForModel(CString& csinst, int nmod,
  584. CString& csmodel)
  585. {
  586. // Declare looping variables and find out how many nonstd sections there are
  587. int n, n2, n3 ;
  588. int numelts = (int) m_ciwnsms.m_csaSections.GetSize() ;
  589. // If this is the first time this function is called, size and initialize
  590. // the "this section has already been added to the SourceDiskFiles" flags.
  591. if (nmod == 0) {
  592. m_cuiaNonStdSecsFlags.SetSize(numelts) ;
  593. for (n = 0 ; n < numelts ; n++)
  594. m_cuiaNonStdSecsFlags[n] = 0 ;
  595. } ;
  596. // Loop through all of the nonstandard sections looking for one that
  597. // references the current model.
  598. CStringArray* pcsa ;
  599. CStringArray* pcsa2 ;
  600. CString cssec ;
  601. for (n = 0 ; n < numelts ; n++) {
  602. // Get a pointer to the names of models that need the current section.
  603. pcsa = (CStringArray*) m_ciwnsms.m_coaModelsNeedingSecs[n] ;
  604. // Check each model in the above list to see if it matches the model
  605. // passed in as an argument to this function.
  606. for (n2 = 0 ; n2 < pcsa->GetSize() ; n2++)
  607. // If a match is found...
  608. if ((*pcsa)[n2] == csmodel) {
  609. // ...add the section name to the model's CopyFiles statement
  610. // (Strip the brackets off first.)...
  611. cssec = m_ciwnsms.m_csaSections[n] ;
  612. cssec = cssec.Mid(1, cssec.GetLength() - 2) ;
  613. csinst += csComma + cssec ;
  614. // ...and make sure that the sections files are listed in the
  615. // SourceDiskFiles section.
  616. if (!m_cuiaNonStdSecsFlags[n]) {
  617. pcsa2 = (CStringArray*) m_ciwnse.m_coaSectionArrays[n] ;
  618. for (n3 = 0 ; n3 < pcsa2->GetSize() ; n3++)
  619. m_csaSrcDskFiles.Add((*pcsa2)[n3]) ; // Add to [SourceDiskFiles] array
  620. m_cuiaNonStdSecsFlags[n] = 1 ;
  621. } ;
  622. break ;
  623. } ;
  624. } ;
  625. }
  626. void CINFWizard::PrepareToRestart()
  627. {
  628. // Set the flags needed to get the pages to reinitialize themselves but
  629. // keep all existing data.
  630. m_ciwm.m_bReInitWData = m_ciwbd.m_bReInitWData = true ;
  631. m_ciwip.m_bReInitWData = m_ciwef.m_bReInitWData = true ;
  632. m_ciwmn.m_bReInitWData = m_ciwnse.m_bReInitWData = true ;
  633. m_ciws.m_bReInitWData = m_ciwif.m_bReInitWData = true ;
  634. m_ciwis.m_bReInitWData = m_ciwds.m_bReInitWData = true ;
  635. m_ciwnsms.m_bReInitWData = m_ciwgpi.m_bReInitWData = true ;
  636. }
  637. BEGIN_MESSAGE_MAP(CINFWizard, CPropertySheet)
  638. //{{AFX_MSG_MAP(CINFWizard)
  639. // NOTE - the ClassWizard will add and remove mapping macros here.
  640. //}}AFX_MSG_MAP
  641. END_MESSAGE_MAP()
  642. /////////////////////////////////////////////////////////////////////////////
  643. // CINFWizard message handlers
  644. /////////////////////////////////////////////////////////////////////////////
  645. // CINFWizWelcome property page
  646. IMPLEMENT_DYNCREATE(CINFWizWelcome, CPropertyPage)
  647. CINFWizWelcome::CINFWizWelcome() : CPropertyPage(CINFWizWelcome::IDD)
  648. {
  649. //{{AFX_DATA_INIT(CINFWizWelcome)
  650. // NOTE: the ClassWizard will add member initialization here
  651. //}}AFX_DATA_INIT
  652. m_bInitialized = false ;
  653. }
  654. CINFWizWelcome::~CINFWizWelcome()
  655. {
  656. }
  657. void CINFWizWelcome::DoDataExchange(CDataExchange* pDX)
  658. {
  659. CPropertyPage::DoDataExchange(pDX);
  660. //{{AFX_DATA_MAP(CINFWizWelcome)
  661. // NOTE: the ClassWizard will add DDX and DDV calls here
  662. //}}AFX_DATA_MAP
  663. }
  664. BEGIN_MESSAGE_MAP(CINFWizWelcome, CPropertyPage)
  665. //{{AFX_MSG_MAP(CINFWizWelcome)
  666. // NOTE: the ClassWizard will add message map macros here
  667. //}}AFX_MSG_MAP
  668. END_MESSAGE_MAP()
  669. /////////////////////////////////////////////////////////////////////////////
  670. // CINFWizWelcome message handlers
  671. BOOL CINFWizWelcome::OnSetActive()
  672. {
  673. // We wish to disable the "Back" button here.
  674. m_pciwParent->SetWizardButtons(PSWIZB_NEXT) ;
  675. m_pciwParent->GetDlgItem(IDHELP)->ShowWindow(SW_HIDE) ;
  676. m_bInitialized = true ; // Page is initialized now
  677. return CPropertyPage::OnSetActive();
  678. }
  679. /////////////////////////////////////////////////////////////////////////////
  680. // CINFWizModels property page
  681. IMPLEMENT_DYNCREATE(CINFWizModels, CPropertyPage)
  682. CINFWizModels::CINFWizModels() : CPropertyPage(CINFWizModels::IDD)
  683. {
  684. //{{AFX_DATA_INIT(CINFWizModels)
  685. // NOTE: the ClassWizard will add member initialization here
  686. //}}AFX_DATA_INIT
  687. // Initialize member variables
  688. m_bInitialized = m_bSelChanged = m_bReInitWData = false ;
  689. m_uNumModels = m_uNumModelsSel = 0 ;
  690. }
  691. CINFWizModels::~CINFWizModels()
  692. {
  693. }
  694. void CINFWizModels::DoDataExchange(CDataExchange* pDX)
  695. {
  696. CPropertyPage::DoDataExchange(pDX);
  697. //{{AFX_DATA_MAP(CINFWizModels)
  698. DDX_Control(pDX, IDC_ModelsList, m_cfelcModels);
  699. //}}AFX_DATA_MAP
  700. }
  701. BEGIN_MESSAGE_MAP(CINFWizModels, CPropertyPage)
  702. //{{AFX_MSG_MAP(CINFWizModels)
  703. // NOTE: the ClassWizard will add message map macros here
  704. //}}AFX_MSG_MAP
  705. END_MESSAGE_MAP()
  706. /////////////////////////////////////////////////////////////////////////////
  707. // CINFWizModels message handlers
  708. BOOL CINFWizModels::OnSetActive()
  709. {
  710. // Reenable the "Back" button.
  711. CString cstmp ; // RAID 0001 move to head from body
  712. m_pciwParent->SetWizardButtons(PSWIZB_NEXT | PSWIZB_BACK) ;
  713. m_cfelcModels.SetFocus() ; // The list control gets the focus
  714. // If this page has been initialized already, make a copy of the current
  715. // selections and set the flag that indicates that the selection may be
  716. // changing. See below for more info.
  717. // RAID 0001
  718. if(NULL != m_pciwParent->m_pcgc ){
  719. CString csFilePath = m_pciwParent->m_pcgc->GetPathName();
  720. CString csModelName = m_pciwParent->m_pcgc->ModelData()->
  721. GetKeywordValue(csFilePath,_T("ModelName"));
  722. m_uNumModels = 1;
  723. m_csaModels.RemoveAll( );
  724. m_csaModels.Add(csModelName);
  725. if (m_bInitialized && !m_bReInitWData)
  726. return CPropertyPage::OnSetActive() ;
  727. m_csToggleStr.LoadString(IDS_INFModelsToggleStr) ;
  728. m_csaInclude.RemoveAll();
  729. m_csaInclude.Add(m_csToggleStr);
  730. }
  731. else {
  732. //END RAID 0001
  733. unsigned u ;
  734. if (m_bInitialized) {
  735. m_csaModelsLast.SetSize(m_uNumModelsSel) ;
  736. for (u = 0 ; u < m_uNumModelsSel ; u++)
  737. m_csaModelsLast[u] = m_csaModels[u] ;
  738. m_bSelChanged = true ;
  739. // Nothing more need be done if the page is not being reinitialized.
  740. if (!m_bReInitWData)
  741. return CPropertyPage::OnSetActive() ;
  742. } ;
  743. // The following info is needed when reinitializing and is used/described
  744. // later.
  745. unsigned unumselected, u2, ureinitidx ;
  746. if (m_bReInitWData)
  747. unumselected = ureinitidx = (unsigned)m_csaModels.GetSize() ;
  748. // Save the number of models in the project and use this number to set the
  749. // length of the models string array.
  750. m_uNumModels = m_pciwParent->GetModelCount() ;
  751. m_csaModels.SetSize(m_uNumModels) ;
  752. if (!m_bReInitWData)
  753. m_csaInclude.RemoveAll() ;
  754. // Load the model names into the models string array. This is straight
  755. // forward if we are NOT reinitializing but more complicated when we are
  756. // reinitializing. In the latter case, the user's previous selections
  757. // must be maintained at the beginning of the array. The rest of the
  758. // models should be added to array after the selections.
  759. // CString cstmp ; RAID 0001
  760. for (u = 0 ; u < m_uNumModels ; u++) {
  761. cstmp = m_pciwParent->GetModel(u).Name() ;
  762. // If not reinitializing, just add the model name to the array.
  763. if (!m_bReInitWData)
  764. m_csaModels[u] = cstmp ;
  765. // Otherwise only add the model name to the array if it is not one of
  766. // the selected models that are already in the array.
  767. else {
  768. for (u2 = 0 ; u2 < unumselected ; u2++)
  769. if (m_csaModels[u2] == cstmp)
  770. break ;
  771. if (u2 >= unumselected)
  772. m_csaModels[ureinitidx++] = cstmp ;
  773. } ;
  774. } ;
  775. // Initialize the list control
  776. } // RAID 0001. else {
  777. m_cfelcModels.InitControl(LVS_EX_FULLROWSELECT, m_uNumModels, 2,
  778. TF_HASTOGGLECOLUMNS+TF_CLICKONROW, 0,
  779. MF_IGNOREINSDEL) ;
  780. // Load the models column in the list control.
  781. cstmp.LoadString(IDS_INFModelsColLab) ;
  782. m_cfelcModels.InitLoadColumn(0, cstmp, COMPUTECOLWIDTH, 20, false, true,
  783. COLDATTYPE_STRING, (CObArray*) &m_csaModels) ;
  784. // Initialize the includes column in the list control.
  785. cstmp.LoadString(IDS_INFIncludesColLab) ;
  786. m_csToggleStr.LoadString(IDS_INFModelsToggleStr) ;
  787. m_cfelcModels.InitLoadColumn(1, cstmp, SETWIDTHTOREMAINDER, -20, false,
  788. true, COLDATTYPE_TOGGLE,
  789. (CObArray*) &m_csaInclude, m_csToggleStr) ;
  790. m_bInitialized = true ; // Page is initialized now
  791. m_bReInitWData = false ; // Reinit is done now on this page
  792. return CPropertyPage::OnSetActive() ;
  793. }
  794. LRESULT CINFWizModels::OnWizardNext()
  795. {
  796. // Make sure the list's contents are sorted in descending order by included
  797. // status.
  798. m_cfelcModels.SortControl(1) ;
  799. if (m_cfelcModels.GetColSortOrder(1))
  800. m_cfelcModels.SortControl(1) ;
  801. // Get the data in the included status column.
  802. m_cfelcModels.GetColumnData((CObArray*) &m_csaInclude, 1) ;
  803. // Complain and don't let the user continue if no models were selected.
  804. if (m_csaInclude.GetSize() == 0 || m_csaInclude[0].IsEmpty()) {
  805. CString csmsg ;
  806. csmsg.LoadString(IDS_INFNoModelsSel) ;
  807. AfxMessageBox(csmsg, MB_ICONEXCLAMATION) ;
  808. return -1 ;
  809. } ;
  810. // Get the data in the models column.
  811. m_cfelcModels.GetColumnData((CObArray*) &m_csaModels, 0) ;
  812. // Determine the number of included models and use this count to resize the
  813. // models array.
  814. m_uNumModelsSel = 0 ;
  815. for (unsigned u = 0 ; u < m_uNumModels ; u++) {
  816. if (m_csaInclude[u].IsEmpty())
  817. break ;
  818. m_uNumModelsSel++ ;
  819. } ;
  820. m_csaModels.SetSize(m_uNumModelsSel) ;
  821. // Call the sheet class to set the the other pages' fixup flags if the
  822. // selection changed.
  823. if (m_bSelChanged) {
  824. m_pciwParent->SetFixupFlags() ;
  825. m_bSelChanged = false ;
  826. } ;
  827. // All went well so move on to the next wizard page.
  828. return CPropertyPage::OnWizardNext() ;
  829. }
  830. int IdentifyOldAndNewModels(CStringArray& csanewmodels, CUIntArray& cuiaoldmodelsfound,
  831. CUIntArray& cuianewmodelsfound, int& newnumelts,
  832. CStringArray& csamodels)
  833. {
  834. int n, n2 ; // Looping variables
  835. // Get the number of models in the new and old lists.
  836. int numelts = (int) csamodels.GetSize() ;
  837. newnumelts = (int) csanewmodels.GetSize() ;
  838. // Declare and initialize flag arrays used to determine which models are
  839. // in use.
  840. cuiaoldmodelsfound.SetSize(numelts) ;
  841. for (n = 0 ; n < numelts ; n++)
  842. cuiaoldmodelsfound[n] = 0 ;
  843. cuianewmodelsfound.SetSize(newnumelts) ;
  844. for (n = 0 ; n < newnumelts ; n++)
  845. cuianewmodelsfound[n] = 0 ;
  846. // Loop through the old & new models to see which of them are still in use.
  847. for (n = 0 ; n < numelts ; n++)
  848. for (n2 = 0 ; n2 < newnumelts ; n2++)
  849. if (csamodels[n] == csanewmodels[n2]) {
  850. cuiaoldmodelsfound[n] = cuianewmodelsfound[n2] = 1 ;
  851. break ;
  852. } ;
  853. // Return the number models previously selected
  854. return numelts ;
  855. }
  856. /////////////////////////////////////////////////////////////////////////////
  857. // CINFWizGetPnPIDs property page
  858. IMPLEMENT_DYNCREATE(CINFWizGetPnPIDs, CPropertyPage)
  859. CINFWizGetPnPIDs::CINFWizGetPnPIDs() : CPropertyPage(CINFWizGetPnPIDs::IDD)
  860. {
  861. //{{AFX_DATA_INIT(CINFWizGetPnPIDs)
  862. // NOTE: the ClassWizard will add member initialization here
  863. //}}AFX_DATA_INIT
  864. m_bInitialized = m_bReInitWData = m_bSelChanged = false ;
  865. }
  866. CINFWizGetPnPIDs::~CINFWizGetPnPIDs()
  867. {
  868. }
  869. void CINFWizGetPnPIDs::DoDataExchange(CDataExchange* pDX)
  870. {
  871. CPropertyPage::DoDataExchange(pDX);
  872. //{{AFX_DATA_MAP(CINFWizGetPnPIDs)
  873. DDX_Control(pDX, IDC_ModelsPnPIDList, m_felcModelIDs);
  874. //}}AFX_DATA_MAP
  875. }
  876. BEGIN_MESSAGE_MAP(CINFWizGetPnPIDs, CPropertyPage)
  877. //{{AFX_MSG_MAP(CINFWizGetPnPIDs)
  878. // NOTE: the ClassWizard will add message map macros here
  879. //}}AFX_MSG_MAP
  880. END_MESSAGE_MAP()
  881. /////////////////////////////////////////////////////////////////////////////
  882. // CINFWizGetPnPIDs message handlers
  883. BOOL CINFWizGetPnPIDs::OnSetActive()
  884. {
  885. // Just perform the default actions if nothing special needs to be done.
  886. if (m_bInitialized && (!m_bReInitWData) && (!m_bSelChanged))
  887. return CPropertyPage::OnSetActive() ;
  888. int n, n2 ; // Looping and indexing variables
  889. // Perform the first time initialization.
  890. if (!m_bInitialized) {
  891. // Get a copy of the selected model names. Then make the PnP ID array
  892. // the same size and initialize each entry to empty.
  893. m_csaModels.Copy(m_pciwParent->GetINFModels()) ;
  894. m_csaModelIDs.SetSize(m_csaModels.GetSize()) ;
  895. for (n = 0 ; n < m_csaModelIDs.GetSize() ; n++)
  896. m_csaModelIDs[n] = csEmpty ;
  897. // Initialize and load the list control
  898. InitModelsIDListCtl() ;
  899. // Set init flag, reset other flags, and return whatever the base class
  900. // function returns.
  901. m_bInitialized = true ;
  902. m_bReInitWData = m_bSelChanged = false ;
  903. return CPropertyPage::OnSetActive() ;
  904. } ;
  905. // Either the selected models have changed or the wizard is being
  906. // reinitialized if this point is reached. They are handled in similar
  907. // ways.
  908. //
  909. // Begin by getting info about the models in this page and the ones that
  910. // are selected now.
  911. CStringArray& csanewmodels = m_pciwParent->GetINFModels() ;
  912. CUIntArray cuiaoldmodelsfound, cuianewmodelsfound ;
  913. int numelts, newnumelts ;
  914. numelts = IdentifyOldAndNewModels(csanewmodels, cuiaoldmodelsfound,
  915. cuianewmodelsfound, newnumelts,
  916. m_csaModels) ;
  917. // Remove the old models and related data that are no longer needed.
  918. for (n = numelts - 1 ; n >= 0 ; n--)
  919. if (cuiaoldmodelsfound[n] == 0) {
  920. m_csaModels.RemoveAt(n) ;
  921. m_csaModelIDs.RemoveAt(n) ;
  922. } ;
  923. // Add the truly new models to this page's array of model names and
  924. // initialize all related data for it.
  925. for (n = n2 = 0 ; n < newnumelts ; n++) {
  926. if (cuianewmodelsfound[n] == 1) {
  927. n2++ ;
  928. continue ;
  929. } ;
  930. m_csaModels.InsertAt(n2, csanewmodels[n]) ;
  931. m_csaModelIDs.InsertAt(n2, csEmpty) ;
  932. } ;
  933. // Reinitialize the list control if the wizard has been reinitialized.
  934. // Otherwise, just reload the columns in the list control.
  935. if (m_bReInitWData)
  936. InitModelsIDListCtl() ;
  937. else {
  938. // If necessary, zap extra old data that could be left in the control
  939. // after the new data is loaded.
  940. if (numelts > newnumelts) {
  941. CStringArray csa ;
  942. csa.SetSize(numelts) ;
  943. for (n = 0 ; n < numelts ; n++)
  944. csa[n] = csEmpty ;
  945. m_felcModelIDs.SetColumnData((CObArray*) &csa, 0) ;
  946. m_felcModelIDs.SetColumnData((CObArray*) &csa, 1) ;
  947. } ;
  948. m_felcModelIDs.SetColumnData((CObArray*) &m_csaModels, 0) ;
  949. m_felcModelIDs.SetColumnData((CObArray*) &m_csaModelIDs, 1) ;
  950. } ;
  951. // Set init flag, reset other flags, and return whatever the base class
  952. // function returns.
  953. m_bInitialized = true ;
  954. m_bReInitWData = m_bSelChanged = false ;
  955. return CPropertyPage::OnSetActive() ;
  956. }
  957. LRESULT CINFWizGetPnPIDs::OnWizardNext()
  958. {
  959. // Get the data in the PnP ID column.
  960. m_felcModelIDs.GetColumnData((CObArray*) &m_csaModelIDs, 1) ;
  961. // Complain and exit without allowing the wizard page to change if a PnP ID
  962. // is found that contains spaces.
  963. int numelts = (int) m_csaModelIDs.GetSize() ;
  964. for (int n = 0 ; n < numelts ; n++) {
  965. if (m_csaModelIDs[n].Find(_T(' ')) >= 0) {
  966. AfxMessageBox(IDS_PnPSpacesError, MB_ICONEXCLAMATION) ;
  967. return -1 ;
  968. } ;
  969. } ;
  970. return CPropertyPage::OnWizardNext();
  971. }
  972. LRESULT CINFWizGetPnPIDs::OnWizardBack()
  973. {
  974. // This works because the same thing needs to be done for both
  975. // OnWizardNext() and OnWizardBack(). In addition,
  976. // CPropertyPage::OnWizardNext() and CPropertyPage::OnWizardBack() just
  977. // return 0.
  978. return OnWizardNext() ;
  979. }
  980. void CINFWizGetPnPIDs::InitModelsIDListCtl()
  981. {
  982. int numelts ; // Number of elements in an array
  983. CString cstmp ;
  984. // Initialize the list control
  985. numelts = (int) m_csaModels.GetSize() ;
  986. m_felcModelIDs.InitControl(LVS_EX_FULLROWSELECT, numelts, 2, 0, 0,
  987. MF_IGNOREINSDEL) ;
  988. // Load the models column in the list control.
  989. cstmp.LoadString(IDS_INFModelsColLab) ;
  990. m_felcModelIDs.InitLoadColumn(0, cstmp, COMPUTECOLWIDTH, 25, false,
  991. false, COLDATTYPE_STRING,
  992. (CObArray*) &m_csaModels) ;
  993. // Initialize the PnP ID column in the list control.
  994. cstmp.LoadString(IDS_INFPnPIDColLab) ;
  995. m_felcModelIDs.InitLoadColumn(1, cstmp, SETWIDTHTOREMAINDER, -25,
  996. true, false, COLDATTYPE_STRING,
  997. (CObArray*) &m_csaModelIDs) ;
  998. }
  999. /////////////////////////////////////////////////////////////////////////////
  1000. // CINFWizBiDi property page
  1001. IMPLEMENT_DYNCREATE(CINFWizBiDi, CPropertyPage)
  1002. CINFWizBiDi::CINFWizBiDi() : CPropertyPage(CINFWizBiDi::IDD)
  1003. {
  1004. //{{AFX_DATA_INIT(CINFWizBiDi)
  1005. // NOTE: the ClassWizard will add member initialization here
  1006. //}}AFX_DATA_INIT
  1007. m_bInitialized = m_bReInitWData = m_bSelChanged = false ;
  1008. }
  1009. CINFWizBiDi::~CINFWizBiDi()
  1010. {
  1011. }
  1012. void CINFWizBiDi::DoDataExchange(CDataExchange* pDX)
  1013. {
  1014. CPropertyPage::DoDataExchange(pDX);
  1015. //{{AFX_DATA_MAP(CINFWizBiDi)
  1016. DDX_Control(pDX, IDC_ModelsList, m_cfelcBiDi);
  1017. //}}AFX_DATA_MAP
  1018. }
  1019. void CINFWizBiDi::ModelChangeFixups(unsigned unummodelssel,
  1020. CStringArray& csamodels,
  1021. CStringArray& csamodelslast)
  1022. {
  1023. // Declare looping vars, get the size of the old selection array, and
  1024. // declare and size a new flags array.
  1025. unsigned u, u2, unumlst ;
  1026. unumlst = (unsigned)csamodelslast.GetSize() ;
  1027. CUIntArray cuaflags ;
  1028. cuaflags.SetSize(unummodelssel) ;
  1029. // Try to find each new model in the list of old models. If found, copy the
  1030. // models flag. If not found, initialize the models flag to false.
  1031. for (u = 0 ; u < unummodelssel ; u++) {
  1032. for (u2 = 0 ; u2 < unumlst ; u2++) {
  1033. if (csamodels[u] == csamodelslast[u2])
  1034. break ;
  1035. } ;
  1036. cuaflags[u] = (u2 < unumlst) ? m_cuaBiDiFlags[u2] : false ;
  1037. } ;
  1038. // Copy the new flags array back into the member variable flags array.
  1039. m_cuaBiDiFlags.SetSize(unummodelssel) ;
  1040. for (u = 0 ; u < unummodelssel ; u++)
  1041. m_cuaBiDiFlags[u] = cuaflags[u] ;
  1042. // Now that the data structures are up to date, load the list control with
  1043. // the new information. (This part only needed if NOT reinitializing.)
  1044. if (!m_bReInitWData) {
  1045. m_cfelcBiDi.SetColumnData((CObArray*) &csamodels, 0) ;
  1046. CString cs ;
  1047. for (u = 0 ; u < unummodelssel ; u++) {
  1048. cs = (m_cuaBiDiFlags[u]) ? m_csToggleStr : csEmpty ;
  1049. VERIFY(m_cfelcBiDi.SetItemText(u, 1, cs)) ;
  1050. } ;
  1051. } ;
  1052. }
  1053. BEGIN_MESSAGE_MAP(CINFWizBiDi, CPropertyPage)
  1054. //{{AFX_MSG_MAP(CINFWizBiDi)
  1055. // NOTE: the ClassWizard will add message map macros here
  1056. //}}AFX_MSG_MAP
  1057. END_MESSAGE_MAP()
  1058. /////////////////////////////////////////////////////////////////////////////
  1059. // CINFWizBiDi message handlers
  1060. BOOL CINFWizBiDi::OnSetActive()
  1061. {
  1062. m_cfelcBiDi.SetFocus() ; // The list control gets the focus
  1063. // Nothing else need be done if this page has been initialized already
  1064. // and it is not being asked to reinitialize the page... That is,
  1065. // except for possibly needing to pick up any selected model changes
  1066. // that were made.
  1067. if (m_bInitialized && !m_bReInitWData) {
  1068. if (m_bSelChanged) {
  1069. ModelChangeFixups(m_pciwParent->GetINFModsSelCount(),
  1070. m_pciwParent->GetINFModels(),
  1071. m_pciwParent->GetINFModelsLst()) ;
  1072. m_bSelChanged = false ;
  1073. } ;
  1074. return CPropertyPage::OnSetActive() ;
  1075. } ;
  1076. // Get the array of selected models and declare an array for BiDi info.
  1077. CStringArray& csamodels = m_pciwParent->GetINFModels() ;
  1078. CStringArray csabidi ;
  1079. unsigned unumelts = (unsigned)csamodels.GetSize() ;
  1080. m_csToggleStr.LoadString(IDS_INFBiDiToggleStr) ;
  1081. // If not reinitializing, make sure the BiDi array is empty. Otherwise,
  1082. // initialize the BiDi strings array based on the settings in the BiDi
  1083. // flags array.
  1084. if (!m_bReInitWData)
  1085. csabidi.RemoveAll() ;
  1086. else {
  1087. ModelChangeFixups(m_pciwParent->GetINFModsSelCount(),
  1088. m_pciwParent->GetINFModels(),
  1089. m_pciwParent->GetINFModelsLst()) ;
  1090. csabidi.SetSize(unumelts) ;
  1091. for (unsigned u = 0 ; u < unumelts ; u++)
  1092. if (m_cuaBiDiFlags[u])
  1093. csabidi[u] = m_csToggleStr ;
  1094. } ;
  1095. // Initialize the list control
  1096. m_cfelcBiDi.InitControl(LVS_EX_FULLROWSELECT, unumelts, 2,
  1097. TF_HASTOGGLECOLUMNS+TF_CLICKONROW, 0,
  1098. MF_IGNOREINSDEL) ;
  1099. // Load the models column in the list control.
  1100. CString cstmp ;
  1101. cstmp.LoadString(IDS_INFModelsColLab) ;
  1102. m_cfelcBiDi.InitLoadColumn(0, cstmp, COMPUTECOLWIDTH, 40, false, true,
  1103. COLDATTYPE_STRING, (CObArray*) &csamodels) ;
  1104. // Initialize the bidi column in the list control.
  1105. cstmp.LoadString(IDS_INFBiDiColLab) ;
  1106. m_cfelcBiDi.InitLoadColumn(1, cstmp, SETWIDTHTOREMAINDER, -20, false, true,
  1107. COLDATTYPE_TOGGLE, (CObArray*) &csabidi,
  1108. m_csToggleStr) ;
  1109. m_bInitialized = true ; // Page is initialized now
  1110. m_bReInitWData = false ; // Reinit (if needed) is done now on this page
  1111. return CPropertyPage::OnSetActive() ;
  1112. }
  1113. LRESULT CINFWizBiDi::OnWizardNext()
  1114. {
  1115. // Make sure the list's contents are sorted in descending order by BI-DI
  1116. // status.
  1117. m_cfelcBiDi.SortControl(1) ;
  1118. if (m_cfelcBiDi.GetColSortOrder(1))
  1119. m_cfelcBiDi.SortControl(1) ;
  1120. // Get the data in the models and BI-DI status columns. Then get the
  1121. // original list of selected models.
  1122. CStringArray csamodels, csabidi ;
  1123. m_cfelcBiDi.GetColumnData((CObArray*) &csamodels, 0) ;
  1124. m_cfelcBiDi.GetColumnData((CObArray*) &csabidi, 1) ;
  1125. CStringArray& csaselmodels = m_pciwParent->GetINFModels() ;
  1126. // Get the length of the arrays and use it to size the array that is used
  1127. // to hold the BI-DI flags.
  1128. unsigned unummodels = (unsigned)csaselmodels.GetSize() ;
  1129. m_cuaBiDiFlags.SetSize(unummodels) ;
  1130. // Now we need to set the BIDI flags correctly. This is complicated a bit
  1131. // because the models array from the Bi-Di list may not be in the same
  1132. // order as the selected models array. The flags array should map to the
  1133. // selected models array. There is extra code below to deal with this.
  1134. for (unsigned u = 0 ; u < unummodels ; u++) {
  1135. for (unsigned u2 = 0 ; u2 < unummodels ; u2++) {
  1136. if (csaselmodels[u] == csamodels[u2]) {
  1137. m_cuaBiDiFlags[u] = !csabidi[u2].IsEmpty() ;
  1138. break ;
  1139. } ;
  1140. } ;
  1141. } ;
  1142. // If this is not the first time this page has been used, any changes made
  1143. // could affect the data managed by some of the other pages. Make a call
  1144. // to fixup that data when needed.
  1145. m_pciwParent->BiDiDataChanged() ;
  1146. // All went well so move on to the next wizard page.
  1147. return CPropertyPage::OnWizardNext() ;
  1148. }
  1149. LRESULT CINFWizBiDi::OnWizardBack()
  1150. {
  1151. // This works because the same thing needs to be done for both
  1152. // OnWizardNext() and OnWizardBack(). In addition,
  1153. // CPropertyPage::OnWizardNext() and CPropertyPage::OnWizardBack() just
  1154. // return 0.
  1155. return OnWizardNext() ;
  1156. }
  1157. void InitListListPage(CListBox& clbmainlst, bool& binit, CINFWizard* pciwparent,
  1158. CObArray& coapermaindata,
  1159. CFullEditListCtrl& cfelcsecondlst, int ncollabid,
  1160. CStringArray& csamain, bool& breinitwdata,
  1161. int& ncurmodelidx, int neditlen, DWORD dwmiscflags)
  1162. {
  1163. clbmainlst.SetFocus() ; // The main list box gets the focus
  1164. // Nothing else need be done if this page has been initialized already and
  1165. // it has not be requested to reinitialize itself while keeping existing
  1166. // data.
  1167. if (binit && !breinitwdata)
  1168. return ;
  1169. // Count the array of items to load into the main list box.
  1170. unsigned unummodels = (unsigned)csamain.GetSize() ;
  1171. // Load the main items into the main list box.
  1172. clbmainlst.ResetContent() ;
  1173. for (unsigned u = 0 ; u < unummodels ; u++)
  1174. clbmainlst.AddString(csamain[u]) ;
  1175. CStringArray* pcsa ;
  1176. // Initialize the array of string array pointers used to manage the data
  1177. // in the second list for each item in the main list. (Only if not
  1178. // reinitializing because the existing data must be maintained in this
  1179. // case.)
  1180. if (!breinitwdata) {
  1181. coapermaindata.SetSize(unummodels) ;
  1182. for (u = 0 ; u < unummodels ; u++) {
  1183. pcsa = new CStringArray ;
  1184. pcsa->RemoveAll() ;
  1185. coapermaindata[u] = (CObArray*) pcsa ;
  1186. } ;
  1187. } ;
  1188. // Initialize the list control
  1189. cfelcsecondlst.InitControl(LVS_EX_FULLROWSELECT+LVS_EX_GRIDLINES, 8, 1, 0,
  1190. neditlen, dwmiscflags) ;
  1191. // Put some bogus entries into a string array that is used to "activate"
  1192. // the list control.
  1193. pcsa = new CStringArray ;
  1194. pcsa->SetSize(8) ;
  1195. for (u = 0 ; u < 8 ; u++)
  1196. pcsa->SetAt(u, csEmpty) ;
  1197. // Initialize the only column in the list control.
  1198. CString cstmp ;
  1199. cstmp.LoadString(ncollabid) ;
  1200. cfelcsecondlst.InitLoadColumn(0, cstmp, SETWIDTHTOREMAINDER, -16, true,
  1201. true, COLDATTYPE_STRING, (CObArray*) pcsa) ;
  1202. delete pcsa ;
  1203. // Now that the list control has been initialized, disable it until a main
  1204. // list item is selected.
  1205. cfelcsecondlst.EnableWindow(false) ;
  1206. ncurmodelidx = -1 ; // Reset the current model index
  1207. binit = true ; // Page is initialized now
  1208. breinitwdata = false ; // Reinit (if needed) is done now on this page
  1209. return ;
  1210. }
  1211. void SelChangedListListPage(CListBox& clbmainlst, bool binit,
  1212. CObArray& coapermaindata,
  1213. CFullEditListCtrl& cfelcsecondlst,
  1214. CButton* pcbbrowse, int& ncurmainidx)
  1215. {
  1216. // Do nothing if the page has not been initialized yet.
  1217. if (!binit)
  1218. return ;
  1219. // Make sure the Profiles list and Browse button are enabled.
  1220. if (pcbbrowse != NULL)
  1221. pcbbrowse->EnableWindow() ;
  1222. cfelcsecondlst.EnableWindow() ;
  1223. // If there was a previous selection in the list box, save that model's
  1224. // filespecs before loading the current model's filespecs.
  1225. CStringArray* pcsa ;
  1226. if (ncurmainidx != -1) {
  1227. cfelcsecondlst.SaveValue() ;
  1228. pcsa = (CStringArray*) coapermaindata[ncurmainidx] ;
  1229. cfelcsecondlst.GetColumnData((CObArray*) pcsa, 0) ;
  1230. } ;
  1231. // Update the current model index and load its filespecs into the list
  1232. // control. Before loading, make sure that the current model's file array
  1233. // is long enough to overwrite all of the last model's file strings that
  1234. // are currently in the list.
  1235. if ((ncurmainidx = clbmainlst.GetCurSel()) != -1) {
  1236. pcsa = (CStringArray*) coapermaindata[ncurmainidx] ;
  1237. int nelts = (int)pcsa->GetSize() ;
  1238. int nrows = cfelcsecondlst.GetItemCount() ;
  1239. if (nelts < nrows) {
  1240. pcsa->SetSize(nrows) ;
  1241. for (int n = nrows ; n < nelts ; n++)
  1242. pcsa->SetAt(n, csEmpty) ;
  1243. } ;
  1244. cfelcsecondlst.SetColumnData((CObArray*) pcsa, 0) ;
  1245. } ;
  1246. }
  1247. void OnBrowseListListPage(CFullEditListCtrl& cfelcsecondlst, int nfiletypeid)
  1248. {
  1249. // Prepare for and prompt the user for a filespec to add to the list
  1250. // control. Return if the user cancels.
  1251. CString cstmp ;
  1252. cstmp.LoadString(nfiletypeid) ;
  1253. CFileDialog cfd(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, cstmp) ;
  1254. if (cfd.DoModal() != IDOK)
  1255. return ;
  1256. // Get the user selected filespec.
  1257. cstmp = cfd.GetPathName() ;
  1258. // Determine the row to place the filespec in
  1259. int nrow ;
  1260. if ((nrow = cfelcsecondlst.GetNextItem(-1, LVNI_SELECTED)) == -1)
  1261. nrow = 0 ;
  1262. // Save the filespec in the profiles list
  1263. VERIFY(cfelcsecondlst.SetItemText(nrow, 0, cstmp)) ;
  1264. }
  1265. void OnWizNextListListPage(int& ncurmainidx, CFullEditListCtrl& cfelcsecondlst,
  1266. CObArray& coapermaindata)
  1267. {
  1268. // If there was a previous selection in the list box, save that item's
  1269. // data.
  1270. CStringArray* pcsa ;
  1271. if (ncurmainidx != -1) {
  1272. cfelcsecondlst.SaveValue() ;
  1273. pcsa = (CStringArray*) coapermaindata[ncurmainidx] ;
  1274. cfelcsecondlst.GetColumnData((CObArray*) pcsa, 0) ;
  1275. } ;
  1276. // Users may not fill every string in the string arrays so get rid of the
  1277. // ones that are empty.
  1278. int nnummodels = (int)coapermaindata.GetSize() ;
  1279. int nnumfiles, n, n2, n3 ;
  1280. for (n = 0 ; n < nnummodels ; n++) {
  1281. pcsa = (CStringArray*) coapermaindata[n] ;
  1282. nnumfiles = (int)pcsa->GetSize() ;
  1283. for (n2 = n3 = 0 ; n2 < nnumfiles ; n2++) {
  1284. (pcsa->GetAt(n3)).TrimLeft() ;
  1285. (pcsa->GetAt(n3)).TrimRight() ;
  1286. if ((pcsa->GetAt(n3)).IsEmpty())
  1287. pcsa->RemoveAt(n3) ;
  1288. else
  1289. n3++ ;
  1290. } ;
  1291. } ;
  1292. }
  1293. void ModelChangeFixupsListListPage(unsigned unummodelssel,
  1294. CStringArray& csamodels,
  1295. CStringArray& csamodelslast,
  1296. CFullEditListCtrl& cfelcsecondlst,
  1297. CObArray& coapermaindata, int& ncurmainidx,
  1298. CButton* pcbbrowse, CListBox& clbmainlst,
  1299. bool& breinitwdata)
  1300. {
  1301. // Declare looping vars, get the size of the old selection array, and
  1302. // declare / size / initialize a new profiles array.
  1303. unsigned u, u2, unumlst, unumrows, unumold ;
  1304. unumlst = (unsigned) csamodelslast.GetSize() ;
  1305. if ((unumrows = cfelcsecondlst.GetItemCount()) == 0)
  1306. unumrows = 8 ;
  1307. CObArray coaprofarrays ;
  1308. CStringArray *pcsa, *pcsaold ;
  1309. coaprofarrays.SetSize(unummodelssel) ;
  1310. for (u = 0 ; u < unummodelssel ; u++) {
  1311. pcsa = new CStringArray ;
  1312. pcsa->SetSize(unumrows) ;
  1313. for (u2 = 0 ; u2 < unumrows ; u2++)
  1314. pcsa->SetAt(u2, csEmpty) ;
  1315. coaprofarrays[u] = (CObArray*) pcsa ;
  1316. } ;
  1317. // Clear the list control if not reinitializing.
  1318. if (!breinitwdata)
  1319. cfelcsecondlst.SetColumnData((CObArray*) coaprofarrays[0], 0) ;
  1320. // Try to find each new model in the list of old models. If found, copy the
  1321. // old model's data to the new profiles array.
  1322. for (u = 0 ; u < unummodelssel ; u++) {
  1323. for (u2 = 0 ; u2 < unumlst ; u2++) {
  1324. if (csamodels[u] == csamodelslast[u2])
  1325. break ;
  1326. } ;
  1327. if (u2 < unumlst) {
  1328. pcsa = (CStringArray*) coaprofarrays[u] ;
  1329. pcsaold = (CStringArray*) coapermaindata[u2] ;
  1330. unumold = (unsigned)pcsaold->GetSize() ;
  1331. for (u2 = 0 ; u2 < unumold ; u2++)
  1332. pcsa->SetAt(u2, pcsaold->GetAt(u2)) ;
  1333. } ;
  1334. } ;
  1335. // Delete all of the old data
  1336. for (u = 0 ; u < (unsigned) coapermaindata.GetSize() ; u++) {
  1337. pcsaold = (CStringArray*) coapermaindata[u] ;
  1338. delete pcsaold ;
  1339. } ;
  1340. // Copy the new data into the member variable
  1341. coapermaindata.SetSize(unummodelssel) ;
  1342. for (u = 0 ; u < unummodelssel ; u++)
  1343. coapermaindata[u] = coaprofarrays[u] ;
  1344. // Now that the data structures are up to date, finish updating the page's
  1345. // controls.
  1346. ncurmainidx = -1 ;
  1347. cfelcsecondlst.EnableWindow(false) ;
  1348. pcbbrowse->EnableWindow(false) ;
  1349. clbmainlst.ResetContent() ;
  1350. for (u = 0 ; u < unummodelssel ; u++)
  1351. clbmainlst.AddString(csamodels[u]) ;
  1352. clbmainlst.SetCurSel(-1) ;
  1353. }
  1354. /////////////////////////////////////////////////////////////////////////////
  1355. // CINFWizICMProfiles property page
  1356. IMPLEMENT_DYNCREATE(CINFWizICMProfiles, CPropertyPage)
  1357. CINFWizICMProfiles::CINFWizICMProfiles() : CPropertyPage(CINFWizICMProfiles::IDD)
  1358. {
  1359. //{{AFX_DATA_INIT(CINFWizICMProfiles)
  1360. //}}AFX_DATA_INIT
  1361. m_bInitialized = m_bReInitWData = m_bSelChanged = false ;
  1362. m_nCurModelIdx = -1 ;
  1363. }
  1364. CINFWizICMProfiles::~CINFWizICMProfiles()
  1365. {
  1366. // Delete the string arrays referenced in m_coaProfileArrays.
  1367. CStringArray* pcsa ;
  1368. for (int n = 0 ; n < m_coaProfileArrays.GetSize() ; n++) {
  1369. pcsa = (CStringArray*) m_coaProfileArrays[n] ;
  1370. delete pcsa ;
  1371. } ;
  1372. }
  1373. void CINFWizICMProfiles::DoDataExchange(CDataExchange* pDX)
  1374. {
  1375. CPropertyPage::DoDataExchange(pDX);
  1376. //{{AFX_DATA_MAP(CINFWizICMProfiles)
  1377. DDX_Control(pDX, IDC_ICMFSpecsLst, m_cfelcICMFSpecs);
  1378. DDX_Control(pDX, IDC_ModelsLst, m_clbModels);
  1379. DDX_Control(pDX, IDC_BrowseBtn, m_cbBrowse);
  1380. //}}AFX_DATA_MAP
  1381. }
  1382. void CINFWizICMProfiles::ModelChangeFixups(unsigned unummodelssel,
  1383. CStringArray& csamodels,
  1384. CStringArray& csamodelslast)
  1385. {
  1386. // Do nothing if the page has not been initialized yet.
  1387. if (!m_bInitialized)
  1388. return ;
  1389. // See ModelChangeFixupsListListPage() for more information.
  1390. ModelChangeFixupsListListPage(unummodelssel, csamodels, csamodelslast,
  1391. m_cfelcICMFSpecs, m_coaProfileArrays,
  1392. m_nCurModelIdx, &m_cbBrowse, m_clbModels,
  1393. m_bReInitWData) ;
  1394. }
  1395. BEGIN_MESSAGE_MAP(CINFWizICMProfiles, CPropertyPage)
  1396. //{{AFX_MSG_MAP(CINFWizICMProfiles)
  1397. ON_BN_CLICKED(IDC_BrowseBtn, OnBrowseBtn)
  1398. ON_LBN_SELCHANGE(IDC_ModelsLst, OnSelchangeModelsLst)
  1399. //}}AFX_MSG_MAP
  1400. END_MESSAGE_MAP()
  1401. /////////////////////////////////////////////////////////////////////////////
  1402. // CINFWizICMProfiles message handlers
  1403. BOOL CINFWizICMProfiles::OnSetActive()
  1404. {
  1405. // Get the list of models to load into the main list box.
  1406. CStringArray& csamodels = m_pciwParent->GetINFModels() ;
  1407. // Nothing else need be done if this page has been initialized already
  1408. // and it is not being asked to reinitialize the page... That is,
  1409. // except for possibly needing to pick up any selected model changes
  1410. // that were made.
  1411. if (m_bInitialized && !m_bReInitWData) {
  1412. if (m_bSelChanged) {
  1413. ModelChangeFixups(m_pciwParent->GetINFModsSelCount(), csamodels,
  1414. m_pciwParent->GetINFModelsLst()) ;
  1415. m_bSelChanged = false ;
  1416. } ;
  1417. return CPropertyPage::OnSetActive() ;
  1418. } ;
  1419. // Pick up selected model changes when reinitializing
  1420. if (m_bReInitWData) {
  1421. ModelChangeFixups(m_pciwParent->GetINFModsSelCount(), csamodels,
  1422. m_pciwParent->GetINFModelsLst()) ;
  1423. m_bSelChanged = false ;
  1424. } ;
  1425. // See InitListListPage() for more details.
  1426. InitListListPage(m_clbModels, m_bInitialized, m_pciwParent,
  1427. m_coaProfileArrays, m_cfelcICMFSpecs, IDS_INFICMColLab,
  1428. csamodels, m_bReInitWData, m_nCurModelIdx, 256, 0) ;
  1429. return CPropertyPage::OnSetActive() ;
  1430. }
  1431. void CINFWizICMProfiles::OnSelchangeModelsLst()
  1432. {
  1433. SelChangedListListPage(m_clbModels, m_bInitialized, m_coaProfileArrays,
  1434. m_cfelcICMFSpecs, &m_cbBrowse, m_nCurModelIdx) ;
  1435. }
  1436. void CINFWizICMProfiles::OnBrowseBtn()
  1437. {
  1438. // See OnBrowseListListPage() for more information.
  1439. OnBrowseListListPage(m_cfelcICMFSpecs, IDS_CommonICMFile) ;
  1440. }
  1441. LRESULT CINFWizICMProfiles::OnWizardNext()
  1442. {
  1443. // Do nothing if the page has not been initialized yet.
  1444. if (!m_bInitialized)
  1445. return -1 ;
  1446. // See OnWizNextListListPage() for more information.
  1447. OnWizNextListListPage(m_nCurModelIdx, m_cfelcICMFSpecs, m_coaProfileArrays);
  1448. return CPropertyPage::OnWizardNext() ;
  1449. }
  1450. LRESULT CINFWizICMProfiles::OnWizardBack()
  1451. {
  1452. // This works because the same thing needs to be done for both
  1453. // OnWizardNext() and OnWizardBack(). In addition,
  1454. // CPropertyPage::OnWizardNext() and CPropertyPage::OnWizardBack() just
  1455. // return 0.
  1456. return OnWizardNext() ;
  1457. }
  1458. /////////////////////////////////////////////////////////////////////////////
  1459. // CINFWizIncludeFiles property page
  1460. IMPLEMENT_DYNCREATE(CINFWizIncludeFiles, CPropertyPage)
  1461. CINFWizIncludeFiles::CINFWizIncludeFiles() : CPropertyPage(CINFWizIncludeFiles::IDD)
  1462. {
  1463. //{{AFX_DATA_INIT(CINFWizIncludeFiles)
  1464. // NOTE: the ClassWizard will add member initialization here
  1465. //}}AFX_DATA_INIT
  1466. m_bInitialized = m_bReInitWData = m_bSelChanged = false ;
  1467. m_nCurModelIdx = -1 ;
  1468. }
  1469. CINFWizIncludeFiles::~CINFWizIncludeFiles()
  1470. {
  1471. }
  1472. void CINFWizIncludeFiles::DoDataExchange(CDataExchange* pDX)
  1473. {
  1474. CPropertyPage::DoDataExchange(pDX);
  1475. //{{AFX_DATA_MAP(CINFWizIncludeFiles)
  1476. DDX_Control(pDX, IDC_ModelsLst, m_clbModels);
  1477. DDX_Control(pDX, IDC_IncludeFileBox, m_ceIncludeFile);
  1478. //}}AFX_DATA_MAP
  1479. }
  1480. BEGIN_MESSAGE_MAP(CINFWizIncludeFiles, CPropertyPage)
  1481. //{{AFX_MSG_MAP(CINFWizIncludeFiles)
  1482. ON_LBN_SELCHANGE(IDC_ModelsLst, OnSelchangeModelsLst)
  1483. //}}AFX_MSG_MAP
  1484. END_MESSAGE_MAP()
  1485. /////////////////////////////////////////////////////////////////////////////
  1486. // CINFWizIncludeFiles message handlers
  1487. BOOL CINFWizIncludeFiles::OnSetActive()
  1488. {
  1489. // Just perform the default actions if nothing special needs to be done.
  1490. if (m_bInitialized && (!m_bReInitWData) && (!m_bSelChanged))
  1491. return CPropertyPage::OnSetActive() ;
  1492. int n, n2 ; // Looping variable
  1493. int numelts, newnumelts ; // Number of elements in an array
  1494. CString cstmp ; // Temp string
  1495. // Perform the first time initialization.
  1496. if (!m_bInitialized) {
  1497. // Get a copy of the currently selected model names and then load them
  1498. // into the list box. Set the focus to the list box.
  1499. m_csaModels.Copy(m_pciwParent->GetINFModels()) ;
  1500. for (n = 0, numelts = (int) m_csaModels.GetSize() ; n < numelts ; n++)
  1501. m_clbModels.AddString(m_csaModels[n]) ;
  1502. m_clbModels.SetFocus() ;
  1503. // Size and initialize the include files array. Initialize each
  1504. // include file to the default.
  1505. cstmp.LoadString(IDS_DefINFIncFile) ;
  1506. m_csaIncFiles.SetSize(numelts) ;
  1507. for (n = 0 ; n < numelts ; n++)
  1508. m_csaIncFiles[n] = cstmp ;
  1509. // Set init flag, reset other flags, and return whatever the base class
  1510. // function returns.
  1511. m_bInitialized = true ;
  1512. m_bReInitWData = m_bSelChanged = false ;
  1513. return CPropertyPage::OnSetActive() ;
  1514. } ;
  1515. // Either the selected models have changed or the wizard is being
  1516. // reinitialized if this point is reached. Both are handled the same way.
  1517. //
  1518. // Begin by getting info about the models in this page and the ones that
  1519. // are selected now.
  1520. CStringArray& csanewmodels = m_pciwParent->GetINFModels() ;
  1521. CUIntArray cuiaoldmodelsfound, cuianewmodelsfound ;
  1522. numelts = IdentifyOldAndNewModels(csanewmodels, cuiaoldmodelsfound,
  1523. cuianewmodelsfound, newnumelts,
  1524. m_csaModels) ;
  1525. // Remove the old models and related data that are no longer needed.
  1526. for (n = numelts - 1 ; n >= 0 ; n--)
  1527. if (cuiaoldmodelsfound[n] == 0) {
  1528. m_csaModels.RemoveAt(n) ;
  1529. m_csaIncFiles.RemoveAt(n) ;
  1530. } ;
  1531. // Add the truly new models to this page's array of model names and
  1532. // initialize an Include File string for it.
  1533. cstmp.LoadString(IDS_DefINFIncFile) ;
  1534. for (n = n2 = 0 ; n < newnumelts ; n++) {
  1535. if (cuianewmodelsfound[n] == 1) {
  1536. n2++ ;
  1537. continue ;
  1538. } ;
  1539. m_csaModels.InsertAt(n2, csanewmodels[n]) ;
  1540. m_csaIncFiles.InsertAt(n2, cstmp) ;
  1541. } ;
  1542. // Clear the Include Files edit box
  1543. m_ceIncludeFile.SetWindowText(csEmpty) ;
  1544. // Reinitialize the models array and the current model index.
  1545. m_clbModels.ResetContent() ;
  1546. for (n = 0, numelts = (int) m_csaModels.GetSize() ; n < numelts ; n++)
  1547. m_clbModels.AddString(m_csaModels[n]) ;
  1548. m_clbModels.SetCurSel(-1) ;
  1549. m_clbModels.SetFocus() ;
  1550. m_nCurModelIdx = -1 ;
  1551. // Set init flag, reset other flags, and return whatever the base class
  1552. // function returns.
  1553. m_bInitialized = true ;
  1554. m_bReInitWData = m_bSelChanged = false ;
  1555. return CPropertyPage::OnSetActive() ;
  1556. }
  1557. void CINFWizIncludeFiles::OnSelchangeModelsLst()
  1558. {
  1559. // If there was a previous model selection, save its include file string.
  1560. // Otherwise, enable the include file edit box.
  1561. if (m_nCurModelIdx != -1)
  1562. m_ceIncludeFile.GetWindowText(m_csaIncFiles[m_nCurModelIdx]) ;
  1563. else
  1564. m_ceIncludeFile.EnableWindow() ;
  1565. // Save the index for the currently selected model. Then load the edit box
  1566. // with the include file string for that model.
  1567. m_nCurModelIdx = m_clbModels.GetCurSel() ;
  1568. m_ceIncludeFile.SetWindowText(m_csaIncFiles[m_nCurModelIdx]) ;
  1569. }
  1570. LRESULT CINFWizIncludeFiles::OnWizardNext()
  1571. {
  1572. // Save the index for the currently selected model. If the value is valid,
  1573. // save the include file string for this model.
  1574. if ((m_nCurModelIdx = m_clbModels.GetCurSel()) != -1)
  1575. m_ceIncludeFile.GetWindowText(m_csaIncFiles[m_nCurModelIdx]) ;
  1576. // Make sure each model has an include file string. Complain and exit
  1577. // without allowing the page to change if an empty string is found.
  1578. int numelts = (int) m_csaIncFiles.GetSize() ;
  1579. for (int n = 0 ; n < numelts ; n++) {
  1580. if (m_csaIncFiles[n].IsEmpty()) {
  1581. CString cserrmsg ;
  1582. cserrmsg.Format(IDS_INFMissingIncError, m_csaModels[n]) ;
  1583. AfxMessageBox(cserrmsg, MB_ICONEXCLAMATION) ;
  1584. m_clbModels.SetCurSel(n) ;
  1585. OnSelchangeModelsLst() ;
  1586. m_ceIncludeFile.SetFocus() ;
  1587. return -1 ;
  1588. } ;
  1589. } ;
  1590. // All went well so...
  1591. return CPropertyPage::OnWizardNext();
  1592. }
  1593. LRESULT CINFWizIncludeFiles::OnWizardBack()
  1594. {
  1595. // This works because the same thing needs to be done for both
  1596. // OnWizardNext() and OnWizardBack(). In addition,
  1597. // CPropertyPage::OnWizardNext() and CPropertyPage::OnWizardBack() just
  1598. // return 0.
  1599. return OnWizardNext() ;
  1600. }
  1601. /////////////////////////////////////////////////////////////////////////////
  1602. // CINFWizInstallSections property page
  1603. IMPLEMENT_DYNCREATE(CINFWizInstallSections, CPropertyPage)
  1604. CINFWizInstallSections::CINFWizInstallSections() : CPropertyPage(CINFWizInstallSections::IDD)
  1605. {
  1606. //{{AFX_DATA_INIT(CINFWizInstallSections)
  1607. m_csOtherSections = _T("");
  1608. m_bOther = FALSE;
  1609. m_bPscript = FALSE;
  1610. m_bTtfsub = FALSE;
  1611. m_bUnidrvBidi = FALSE;
  1612. m_bUnidrv = FALSE;
  1613. //}}AFX_DATA_INIT
  1614. m_bInitialized = m_bReInitWData = m_bSelChanged = false ;
  1615. m_nCurModelIdx = -1 ;
  1616. }
  1617. CINFWizInstallSections::~CINFWizInstallSections()
  1618. {
  1619. // Delete the flag arrays referenced in m_coaStdInstSecs.
  1620. CUIntArray* pcuia ;
  1621. for (int n = 0 ; n < m_coaStdInstSecs.GetSize() ; n++) {
  1622. pcuia = (CUIntArray*) m_coaStdInstSecs[n] ;
  1623. delete pcuia ;
  1624. } ;
  1625. }
  1626. void CINFWizInstallSections::DoDataExchange(CDataExchange* pDX)
  1627. {
  1628. CPropertyPage::DoDataExchange(pDX);
  1629. //{{AFX_DATA_MAP(CINFWizInstallSections)
  1630. DDX_Control(pDX, IDC_ModelsLst, m_clbModels);
  1631. DDX_Text(pDX, IDC_OtherBox, m_csOtherSections);
  1632. DDX_Check(pDX, IDC_OtherChk, m_bOther);
  1633. DDX_Check(pDX, IDC_PscriptChk, m_bPscript);
  1634. DDX_Check(pDX, IDC_TtfsubChk, m_bTtfsub);
  1635. DDX_Check(pDX, IDC_UnidrvBidiChk, m_bUnidrvBidi);
  1636. DDX_Check(pDX, IDC_UnidrvChk, m_bUnidrv);
  1637. //}}AFX_DATA_MAP
  1638. }
  1639. BEGIN_MESSAGE_MAP(CINFWizInstallSections, CPropertyPage)
  1640. //{{AFX_MSG_MAP(CINFWizInstallSections)
  1641. ON_LBN_SELCHANGE(IDC_ModelsLst, OnSelchangeModelsLst)
  1642. ON_BN_CLICKED(IDC_OtherChk, OnOtherChk)
  1643. ON_BN_CLICKED(IDC_PscriptChk, OnPscriptChk)
  1644. ON_BN_CLICKED(IDC_TtfsubChk, OnTtfsubChk)
  1645. ON_BN_CLICKED(IDC_UnidrvBidiChk, OnUnidrvBidiChk)
  1646. ON_BN_CLICKED(IDC_UnidrvChk, OnUnidrvChk)
  1647. //}}AFX_MSG_MAP
  1648. END_MESSAGE_MAP()
  1649. /////////////////////////////////////////////////////////////////////////////
  1650. // CINFWizInstallSections message handlers
  1651. BOOL CINFWizInstallSections::OnSetActive()
  1652. {
  1653. // Just perform the default actions if nothing special needs to be done.
  1654. if (m_bInitialized && (!m_bReInitWData) && (!m_bSelChanged))
  1655. return CPropertyPage::OnSetActive() ;
  1656. int n, n2 ; // Looping variable
  1657. int numelts, newnumelts ; // Number of elements in an array
  1658. CUIntArray* pcuia ; // Used to reference a model's flags array
  1659. // Perform the first time initialization.
  1660. if (!m_bInitialized) {
  1661. // Get a copy of the currently selected model names and initialize the
  1662. // controls on this page.
  1663. m_csaModels.Copy(m_pciwParent->GetINFModels()) ;
  1664. numelts = InitPageControls() ;
  1665. // Size and initialize the standard install sections array. There is
  1666. // one entry in the array per model. Each entry references an array
  1667. // of flags that specify the install sections for each model. See
  1668. // below to see how the flags are initialized.
  1669. //
  1670. // The other install sections string array is sized and initialized too.
  1671. m_coaStdInstSecs.SetSize(numelts) ;
  1672. m_csaOtherInstSecs.SetSize(numelts) ;
  1673. for (n = 0 ; n < numelts ; n++)
  1674. AddModelFlags(n) ;
  1675. // Set init flag, reset other flags, and return whatever the base class
  1676. // function returns.
  1677. m_bInitialized = true ;
  1678. m_bReInitWData = m_bSelChanged = false ;
  1679. return CPropertyPage::OnSetActive() ;
  1680. } ;
  1681. // Either the selected models have changed or the wizard is being
  1682. // reinitialized if this point is reached. Both are handled the same way.
  1683. //
  1684. // Begin by getting info about the models in this page and the ones that
  1685. // are selected now.
  1686. CStringArray& csanewmodels = m_pciwParent->GetINFModels() ;
  1687. CUIntArray cuiaoldmodelsfound, cuianewmodelsfound ;
  1688. numelts = IdentifyOldAndNewModels(csanewmodels, cuiaoldmodelsfound,
  1689. cuianewmodelsfound, newnumelts,
  1690. m_csaModels) ;
  1691. // Remove the old models and related data that are no longer needed.
  1692. for (n = numelts - 1 ; n >= 0 ; n--)
  1693. if (cuiaoldmodelsfound[n] == 0) {
  1694. m_csaModels.RemoveAt(n) ;
  1695. pcuia = (CUIntArray*) m_coaStdInstSecs[n] ;
  1696. delete pcuia ;
  1697. m_coaStdInstSecs.RemoveAt(n) ;
  1698. m_csaOtherInstSecs.RemoveAt(n) ;
  1699. } ;
  1700. // Add the truly new models to this page's array of model names and
  1701. // initialize all related Install Section data for it.
  1702. for (n = n2 = 0 ; n < newnumelts ; n++) {
  1703. if (cuianewmodelsfound[n] == 1) {
  1704. n2++ ;
  1705. continue ;
  1706. } ;
  1707. m_csaModels.InsertAt(n2, csanewmodels[n]) ;
  1708. m_coaStdInstSecs.InsertAt(n2, (CObject*) NULL) ;
  1709. m_csaOtherInstSecs.InsertAt(n2, csEmpty) ;
  1710. AddModelFlags(n2) ;
  1711. } ;
  1712. // Initialize the controls on the page
  1713. InitPageControls() ;
  1714. // Set init flag, reset other flags, and return whatever the base class
  1715. // function returns.
  1716. m_bInitialized = true ;
  1717. m_bReInitWData = m_bSelChanged = false ;
  1718. return CPropertyPage::OnSetActive() ;
  1719. }
  1720. void CINFWizInstallSections::AddModelFlags(int nidx)
  1721. {
  1722. int n ; // Looping variable
  1723. CUIntArray* pcuia ; // Used to reference a model's flags array
  1724. CString csfname ; // Model's file name
  1725. // Allocate the flags array and save it in the array of flags arrays.
  1726. // Next, initialize the other sections string for this model.
  1727. pcuia = new CUIntArray ;
  1728. m_coaStdInstSecs[nidx] = (CObArray*) pcuia ;
  1729. m_csaOtherInstSecs[nidx].Empty() ;
  1730. // Size the current flags array and initialize each one to 0 (off).
  1731. pcuia->SetSize(NUMINSTSECFLAGS) ;
  1732. for (n = 0 ; n < NUMINSTSECFLAGS ; n++)
  1733. (*pcuia)[n] = 0 ;
  1734. // Get the model's file name and check its extension to see if
  1735. // one of its Unidrv or its PostScript flag should be set. (The
  1736. // other flags are only user settable so they aren't changed.)
  1737. //RAID 0001
  1738. csfname = m_pciwParent->GetModelFile(m_csaModels[nidx]) ;
  1739. if (csfname.Find(_T(".GPD")) != -1) {
  1740. // The UNIDRVBIDI section is used (flagged) if the user marked
  1741. // this model BIDI. Otherwise, the UNIDRV section is used.
  1742. if (m_pciwParent->m_ciwbd.m_cuaBiDiFlags[nidx])
  1743. (*pcuia)[ISF_UNIBIDI] = 1 ;
  1744. else
  1745. (*pcuia)[ISF_UNI] = 1 ;
  1746. // Postcript file.
  1747. } else
  1748. (*pcuia)[ISF_PSCR] = 1 ;
  1749. }
  1750. int CINFWizInstallSections::InitPageControls()
  1751. {
  1752. int n ; // Looping variable
  1753. int numelts ; // Number of elements in an array
  1754. // Load the current set of models into the list box
  1755. m_clbModels.ResetContent() ;
  1756. for (n = 0, numelts = (int) m_csaModels.GetSize() ; n < numelts ; n++)
  1757. m_clbModels.AddString(m_csaModels[n]) ;
  1758. // Make sure there is no model selected in the list box and that the box
  1759. // has the focus.
  1760. m_clbModels.SetCurSel(-1) ;
  1761. m_clbModels.SetFocus() ;
  1762. m_nCurModelIdx = -1 ;
  1763. // Clear and disable all of the check boxes and the Other edit box.
  1764. for (n = IDC_UnidrvChk ; n <= IDC_TtfsubChk ; n++)
  1765. GetDlgItem(n)->EnableWindow(FALSE) ;
  1766. GetDlgItem(IDC_OtherBox)->EnableWindow(FALSE) ;
  1767. m_bUnidrv = m_bUnidrvBidi = m_bPscript = m_bTtfsub = m_bOther = FALSE ;
  1768. m_csOtherSections = csEmpty ;
  1769. UpdateData(FALSE) ;
  1770. // Return the number of elements in the list box. Ie, the number of
  1771. // selected models.
  1772. return numelts ;
  1773. }
  1774. LRESULT CINFWizInstallSections::OnWizardNext()
  1775. {
  1776. // Save the index for the currently selected model. If the value is valid,
  1777. // save the install section data for this model.
  1778. if ((m_nCurModelIdx = m_clbModels.GetCurSel()) != -1) {
  1779. UpdateData(TRUE) ;
  1780. CUIntArray* pcuia = (CUIntArray*) m_coaStdInstSecs[m_nCurModelIdx] ;
  1781. (*pcuia)[ISF_UNI] = (unsigned) m_bUnidrv ;
  1782. (*pcuia)[ISF_UNIBIDI] = (unsigned) m_bUnidrvBidi ;
  1783. (*pcuia)[ISF_PSCR] = (unsigned) m_bPscript ;
  1784. (*pcuia)[ISF_TTF] = (unsigned) m_bTtfsub ;
  1785. if ((*pcuia)[ISF_OTHER] = (unsigned) m_bOther)
  1786. m_csaOtherInstSecs[m_nCurModelIdx] = m_csOtherSections ;
  1787. } ;
  1788. // Make sure that each model has one of the main sections selected and, if
  1789. // the Other section was selected, it has an Other string.
  1790. CString cserrmsg ;
  1791. CUIntArray* pcuia ;
  1792. int numelts = (int) m_csaModels.GetSize() ;
  1793. for (int n = 0 ; n < numelts ; n++) {
  1794. pcuia = (CUIntArray*) m_coaStdInstSecs[n] ;
  1795. TRACE("*** %s: ISF_UNI=%d ISF_UNIBIDI=%d ISF_PSCR=%d ISF_OTHER=%d\n", m_csaModels[n], (*pcuia)[ISF_UNI], (*pcuia)[ISF_UNIBIDI], (*pcuia)[ISF_PSCR], (*pcuia)[ISF_OTHER]) ;
  1796. if ((*pcuia)[ISF_UNI] == 0 && (*pcuia)[ISF_UNIBIDI] == 0
  1797. && (*pcuia)[ISF_PSCR] == 0 && (*pcuia)[ISF_OTHER] == 0) {
  1798. cserrmsg.Format(IDS_INFMissingInstSecError, m_csaModels[n]) ;
  1799. AfxMessageBox(cserrmsg, MB_ICONEXCLAMATION) ;
  1800. m_clbModels.SetCurSel(n) ;
  1801. OnSelchangeModelsLst() ;
  1802. return -1 ;
  1803. } ;
  1804. if ((*pcuia)[ISF_OTHER] && m_csaOtherInstSecs[n].IsEmpty()) {
  1805. cserrmsg.Format(IDS_INFNoOtherStrError, m_csaModels[n]) ;
  1806. AfxMessageBox(cserrmsg, MB_ICONEXCLAMATION) ;
  1807. m_clbModels.SetCurSel(n) ;
  1808. OnSelchangeModelsLst() ;
  1809. return -1 ;
  1810. } ;
  1811. } ;
  1812. // All went well so...
  1813. return CPropertyPage::OnWizardNext();
  1814. }
  1815. LRESULT CINFWizInstallSections::OnWizardBack()
  1816. {
  1817. // This works because the same thing needs to be done for both
  1818. // OnWizardNext() and OnWizardBack(). In addition,
  1819. // CPropertyPage::OnWizardNext() and CPropertyPage::OnWizardBack() just
  1820. // return 0.
  1821. return OnWizardNext() ;
  1822. }
  1823. void CINFWizInstallSections::OnSelchangeModelsLst()
  1824. {
  1825. // If there was a previous model selection, save its install section flags.
  1826. // Otherwise, enable the install section check boxes.
  1827. if (m_nCurModelIdx != -1) {
  1828. UpdateData(TRUE) ;
  1829. CUIntArray* pcuia = (CUIntArray*) m_coaStdInstSecs[m_nCurModelIdx] ;
  1830. (*pcuia)[ISF_UNI] = (unsigned) m_bUnidrv ;
  1831. (*pcuia)[ISF_UNIBIDI] = (unsigned) m_bUnidrvBidi ;
  1832. (*pcuia)[ISF_PSCR] = (unsigned) m_bPscript ;
  1833. (*pcuia)[ISF_TTF] = (unsigned) m_bTtfsub ;
  1834. if ((*pcuia)[ISF_OTHER] = (unsigned) m_bOther)
  1835. m_csaOtherInstSecs[m_nCurModelIdx] = m_csOtherSections ;
  1836. } else {
  1837. for (int n = IDC_UnidrvChk ; n <= IDC_TtfsubChk ; n++)
  1838. GetDlgItem(n)->EnableWindow(TRUE) ;
  1839. } ;
  1840. // Save the index for the currently selected model. Then set the check
  1841. // boxes based on the flags for the specified model.
  1842. m_nCurModelIdx = m_clbModels.GetCurSel() ;
  1843. CUIntArray* pcuia = (CUIntArray*) m_coaStdInstSecs[m_nCurModelIdx] ;
  1844. m_bUnidrv = (BOOL) ((*pcuia)[ISF_UNI]) ;
  1845. m_bUnidrvBidi = (BOOL) ((*pcuia)[ISF_UNIBIDI]) ;
  1846. m_bPscript = (BOOL) ((*pcuia)[ISF_PSCR]) ;
  1847. m_bTtfsub = (BOOL) ((*pcuia)[ISF_TTF]) ;
  1848. if (m_bOther = (BOOL) ((*pcuia)[ISF_OTHER]))
  1849. m_csOtherSections = m_csaOtherInstSecs[m_nCurModelIdx] ;
  1850. else
  1851. m_csOtherSections = csEmpty ;
  1852. GetDlgItem(IDC_OtherBox)->EnableWindow(m_bOther) ;
  1853. UpdateData(FALSE) ;
  1854. }
  1855. void CINFWizInstallSections::OnPscriptChk()
  1856. {
  1857. // If the PostScript checkbox is checked, the Unidrv and TrueType check
  1858. // boxes must be unchecked.
  1859. UpdateData(TRUE) ;
  1860. if (m_bPscript) {
  1861. m_bTtfsub = m_bUnidrvBidi = m_bUnidrv = FALSE ;
  1862. UpdateData(FALSE) ;
  1863. }
  1864. }
  1865. void CINFWizInstallSections::OnTtfsubChk()
  1866. {
  1867. // If the TrueType box is checked, clear the PostScript checkbox.
  1868. UpdateData(TRUE) ;
  1869. if (m_bTtfsub) {
  1870. m_bPscript = FALSE ;
  1871. UpdateData(FALSE) ;
  1872. }
  1873. }
  1874. void CINFWizInstallSections::OnUnidrvBidiChk()
  1875. {
  1876. // If the UNIDRV_BIDI box is checked, the UNIDRV and PostScript flags must
  1877. // be unchecked.
  1878. UpdateData(TRUE) ;
  1879. if (m_bUnidrvBidi) {
  1880. m_bPscript = m_bUnidrv = FALSE ;
  1881. UpdateData(FALSE) ;
  1882. }
  1883. }
  1884. void CINFWizInstallSections::OnUnidrvChk()
  1885. {
  1886. // If the UNIDRV box is checked, the UNIDRV_BIDI and PostScript flags must
  1887. // be unchecked.
  1888. UpdateData(TRUE) ;
  1889. if (m_bUnidrv) {
  1890. m_bPscript = m_bUnidrvBidi = FALSE ;
  1891. UpdateData(FALSE) ;
  1892. }
  1893. }
  1894. void CINFWizInstallSections::OnOtherChk()
  1895. {
  1896. // Enable or disable the Other sections edit box based on the new state of
  1897. // the Other check box.
  1898. UpdateData(TRUE) ;
  1899. GetDlgItem(IDC_OtherBox)->EnableWindow(m_bOther) ;
  1900. // If the Other check box was just checked, move the focus to the Other box.
  1901. if (m_bOther)
  1902. GetDlgItem(IDC_OtherBox)->SetFocus() ;
  1903. }
  1904. void CINFWizInstallSections::BiDiDataChanged()
  1905. {
  1906. // Do nothing if this page has not be initialized yet. In addition, do
  1907. // nothing if the selected models may have changed or a reinit has been
  1908. // request. These cases are taken care of in OnSetActive(). In additon,
  1909. // it allows this routine to know that the model data in this page are in
  1910. // the same order as the data in the BiDi page().
  1911. if (!m_bInitialized || m_bReInitWData || m_bSelChanged)
  1912. return ;
  1913. // Loop through the data for each selected model and make sure it agrees
  1914. // as much as possible with the current BiDi settings.
  1915. CUIntArray* pcuia ;
  1916. for (int n = 0 ; n < m_coaStdInstSecs.GetSize() ; n++) {
  1917. pcuia = (CUIntArray*) m_coaStdInstSecs[n] ;
  1918. // If the model's BiDi flag is set, make sure it is set here and that
  1919. // its Unidriv and PScript flags are clear.
  1920. if (m_pciwParent->m_ciwbd.m_cuaBiDiFlags[n]) {
  1921. (*pcuia)[ISF_UNIBIDI] = 1 ;
  1922. (*pcuia)[ISF_UNI] = (*pcuia)[ISF_PSCR] = 0 ;
  1923. // Otherwise, clear the BiDi flag. Then set the Unidrv flag if the
  1924. // PScript flag is clear.
  1925. } else {
  1926. (*pcuia)[ISF_UNIBIDI] = 0 ;
  1927. if ((*pcuia)[ISF_PSCR] == 0)
  1928. (*pcuia)[ISF_UNI] = 1 ;
  1929. } ;
  1930. } ;
  1931. // Reinitialize the controls on the page.
  1932. InitPageControls() ;
  1933. }
  1934. //////////////////////////////////////////////////////////////////////////
  1935. // CINFWizDataSections property page
  1936. IMPLEMENT_DYNCREATE(CINFWizDataSections, CPropertyPage)
  1937. CINFWizDataSections::CINFWizDataSections() : CPropertyPage(CINFWizDataSections::IDD)
  1938. {
  1939. //{{AFX_DATA_INIT(CINFWizDataSections)
  1940. m_csOtherSections = _T("");
  1941. m_bOther = FALSE;
  1942. m_bPscript = FALSE;
  1943. m_bUnidrvBidi = FALSE;
  1944. m_bUnidrv = FALSE;
  1945. //}}AFX_DATA_INIT
  1946. m_bInitialized = m_bReInitWData = m_bSelChanged = false ;
  1947. m_nCurModelIdx = -1 ;
  1948. }
  1949. CINFWizDataSections::~CINFWizDataSections()
  1950. {
  1951. // Delete the flag arrays referenced in m_coaStdDataSecs.
  1952. CUIntArray* pcuia ;
  1953. for (int n = 0 ; n < m_coaStdDataSecs.GetSize() ; n++) {
  1954. pcuia = (CUIntArray*) m_coaStdDataSecs[n] ;
  1955. delete pcuia ;
  1956. } ;
  1957. }
  1958. void CINFWizDataSections::DoDataExchange(CDataExchange* pDX)
  1959. {
  1960. CPropertyPage::DoDataExchange(pDX);
  1961. //{{AFX_DATA_MAP(CINFWizDataSections)
  1962. DDX_Control(pDX, IDC_ModelsLst, m_clbModels);
  1963. DDX_Text(pDX, IDC_OtherBox, m_csOtherSections);
  1964. DDX_Check(pDX, IDC_OtherChk, m_bOther);
  1965. DDX_Check(pDX, IDC_PscriptChk, m_bPscript);
  1966. DDX_Check(pDX, IDC_UnidrvBidiChk, m_bUnidrvBidi);
  1967. DDX_Check(pDX, IDC_UnidrvChk, m_bUnidrv);
  1968. //}}AFX_DATA_MAP
  1969. }
  1970. BEGIN_MESSAGE_MAP(CINFWizDataSections, CPropertyPage)
  1971. //{{AFX_MSG_MAP(CINFWizDataSections)
  1972. ON_LBN_SELCHANGE(IDC_ModelsLst, OnSelchangeModelsLst)
  1973. ON_BN_CLICKED(IDC_OtherChk, OnOtherChk)
  1974. ON_BN_CLICKED(IDC_PscriptChk, OnPscriptChk)
  1975. ON_BN_CLICKED(IDC_UnidrvBidiChk, OnUnidrvBidiChk)
  1976. ON_BN_CLICKED(IDC_UnidrvChk, OnUnidrvChk)
  1977. //}}AFX_MSG_MAP
  1978. END_MESSAGE_MAP()
  1979. /////////////////////////////////////////////////////////////////////////////
  1980. // CINFWizDataSections message handlers
  1981. BOOL CINFWizDataSections::OnSetActive()
  1982. {
  1983. // Just perform the default actions if nothing special needs to be done.
  1984. if (m_bInitialized && (!m_bReInitWData) && (!m_bSelChanged))
  1985. return CPropertyPage::OnSetActive() ;
  1986. int n, n2 ; // Looping variable
  1987. int numelts, newnumelts ; // Number of elements in an array
  1988. CUIntArray* pcuia ; // Used to reference a model's flags array
  1989. // Perform the first time initialization.
  1990. if (!m_bInitialized) {
  1991. // Get a copy of the currently selected model names and initialize the
  1992. // controls on this page.
  1993. m_csaModels.Copy(m_pciwParent->GetINFModels()) ;
  1994. numelts = InitPageControls() ;
  1995. // Size and initialize the standard data sections array. There is
  1996. // one entry in the array per model. Each entry references an array
  1997. // of flags that specify the data sections for each model. See
  1998. // below to see how the flags are initialized.
  1999. //
  2000. // The other data sections string array is sized and initialized too.
  2001. m_coaStdDataSecs.SetSize(numelts) ;
  2002. m_csaOtherDataSecs.SetSize(numelts) ;
  2003. for (n = 0 ; n < numelts ; n++)
  2004. AddModelFlags(n) ;
  2005. // Set init flag, reset other flags, and return whatever the base class
  2006. // function returns.
  2007. m_bInitialized = true ;
  2008. m_bReInitWData = m_bSelChanged = false ;
  2009. return CPropertyPage::OnSetActive() ;
  2010. } ;
  2011. // Either the selected models have changed or the wizard is being
  2012. // reinitialized if this point is reached. Both are handled the same way.
  2013. //
  2014. // Begin by getting info about the models in this page and the ones that
  2015. // are selected now.
  2016. CStringArray& csanewmodels = m_pciwParent->GetINFModels() ;
  2017. CUIntArray cuiaoldmodelsfound, cuianewmodelsfound ;
  2018. numelts = IdentifyOldAndNewModels(csanewmodels, cuiaoldmodelsfound,
  2019. cuianewmodelsfound, newnumelts,
  2020. m_csaModels) ;
  2021. // Remove the old models and related data that are no longer needed.
  2022. for (n = numelts - 1 ; n >= 0 ; n--)
  2023. if (cuiaoldmodelsfound[n] == 0) {
  2024. m_csaModels.RemoveAt(n) ;
  2025. pcuia = (CUIntArray*) m_coaStdDataSecs[n] ;
  2026. delete pcuia ;
  2027. m_coaStdDataSecs.RemoveAt(n) ;
  2028. m_csaOtherDataSecs.RemoveAt(n) ;
  2029. } ;
  2030. // Add the truly new models to this page's array of model names and
  2031. // initialize all related Data Section data for it.
  2032. for (n = n2 = 0 ; n < newnumelts ; n++) {
  2033. if (cuianewmodelsfound[n] == 1) {
  2034. n2++ ;
  2035. continue ;
  2036. } ;
  2037. m_csaModels.InsertAt(n2, csanewmodels[n]) ;
  2038. m_coaStdDataSecs.InsertAt(n2, (CObject*) NULL) ;
  2039. m_csaOtherDataSecs.InsertAt(n2, csEmpty) ;
  2040. AddModelFlags(n2) ;
  2041. } ;
  2042. // Initialize the controls on the page
  2043. InitPageControls() ;
  2044. // Set init flag, reset other flags, and return whatever the base class
  2045. // function returns.
  2046. m_bInitialized = true ;
  2047. m_bReInitWData = m_bSelChanged = false ;
  2048. return CPropertyPage::OnSetActive() ;
  2049. }
  2050. void CINFWizDataSections::AddModelFlags(int nidx)
  2051. {
  2052. int n ; // Looping variable
  2053. CUIntArray* pcuia ; // Used to reference a model's flags array
  2054. CString csfname ; // Model's file name
  2055. // Allocate the flags array and save it in the array of flags arrays.
  2056. // Next, initialize the other sections string for this model.
  2057. pcuia = new CUIntArray ;
  2058. m_coaStdDataSecs[nidx] = (CObArray*) pcuia ;
  2059. m_csaOtherDataSecs[nidx].Empty() ;
  2060. // Size the current flags array and initialize each one to 0 (off).
  2061. pcuia->SetSize(NUMDATASECFLAGS) ;
  2062. for (n = 0 ; n < NUMDATASECFLAGS ; n++)
  2063. (*pcuia)[n] = 0 ;
  2064. // Get the model's file name and check its extension to see if
  2065. // one of its Unidrv or its PostScript flag should be set. (The
  2066. // other flags are only user settable so they aren't changed.)
  2067. csfname = m_pciwParent->GetModelFile(m_csaModels[nidx]) ;
  2068. if (csfname.Find(_T(".GPD")) != -1) {
  2069. // The UNIDRVBIDI section is used (flagged) if the user marked
  2070. // this model BIDI. Otherwise, the UNIDRV section is used.
  2071. if (m_pciwParent->m_ciwbd.m_cuaBiDiFlags[nidx])
  2072. (*pcuia)[IDF_UNIBIDI] = 1 ;
  2073. else
  2074. (*pcuia)[IDF_UNI] = 1 ;
  2075. // Postcript file.
  2076. } else
  2077. (*pcuia)[IDF_PSCR] = 1 ;
  2078. }
  2079. int CINFWizDataSections::InitPageControls()
  2080. {
  2081. int n ; // Looping variable
  2082. int numelts ; // Number of elements in an array
  2083. // Load the current set of models into the list box
  2084. m_clbModels.ResetContent() ;
  2085. for (n = 0, numelts = (int) m_csaModels.GetSize() ; n < numelts ; n++)
  2086. m_clbModels.AddString(m_csaModels[n]) ;
  2087. // Make sure there is no model selected in the list box and that the box
  2088. // has the focus.
  2089. m_clbModels.SetCurSel(-1) ;
  2090. m_clbModels.SetFocus() ;
  2091. m_nCurModelIdx = -1 ;
  2092. // Clear and disable all of the check boxes and the Other edit box.
  2093. for (n = IDC_UnidrvChk ; n <= IDC_OtherChk ; n++)
  2094. GetDlgItem(n)->EnableWindow(FALSE) ;
  2095. GetDlgItem(IDC_OtherBox)->EnableWindow(FALSE) ;
  2096. m_bUnidrv = m_bUnidrvBidi = m_bPscript = m_bOther = FALSE ;
  2097. m_csOtherSections = csEmpty ;
  2098. UpdateData(FALSE) ;
  2099. // Return the number of elements in the list box. Ie, the number of
  2100. // selected models.
  2101. return numelts ;
  2102. }
  2103. LRESULT CINFWizDataSections::OnWizardNext()
  2104. {
  2105. // Save the index for the currently selected model. If the value is valid,
  2106. // save the install section data for this model.
  2107. if ((m_nCurModelIdx = m_clbModels.GetCurSel()) != -1) {
  2108. UpdateData(TRUE) ;
  2109. CUIntArray* pcuia = (CUIntArray*) m_coaStdDataSecs[m_nCurModelIdx] ;
  2110. (*pcuia)[IDF_UNI] = (unsigned) m_bUnidrv ;
  2111. (*pcuia)[IDF_UNIBIDI] = (unsigned) m_bUnidrvBidi ;
  2112. (*pcuia)[IDF_PSCR] = (unsigned) m_bPscript ;
  2113. if ((*pcuia)[IDF_OTHER] = (unsigned) m_bOther)
  2114. m_csaOtherDataSecs[m_nCurModelIdx] = m_csOtherSections ;
  2115. } ;
  2116. // Make sure that each model has one of the main sections selected and, if
  2117. // the Other section was selected, it has an Other string.
  2118. CString cserrmsg ;
  2119. CUIntArray* pcuia ;
  2120. int numelts = (int) m_csaModels.GetSize() ;
  2121. for (int n = 0 ; n < numelts ; n++) {
  2122. pcuia = (CUIntArray*) m_coaStdDataSecs[n] ;
  2123. TRACE("*** %s: IDF_UNI=%d IDF_UNIBIDI=%d IDF_PSCR=%d IDF_OTHER=%d\n", m_csaModels[n], (*pcuia)[IDF_UNI], (*pcuia)[IDF_UNIBIDI], (*pcuia)[IDF_PSCR], (*pcuia)[IDF_OTHER]) ;
  2124. if ((*pcuia)[IDF_UNI] == 0 && (*pcuia)[IDF_UNIBIDI] == 0
  2125. && (*pcuia)[IDF_PSCR] == 0 && (*pcuia)[IDF_OTHER] == 0) {
  2126. cserrmsg.Format(IDS_INFMissingDataSecError, m_csaModels[n]) ;
  2127. AfxMessageBox(cserrmsg, MB_ICONEXCLAMATION) ;
  2128. m_clbModels.SetCurSel(n) ;
  2129. OnSelchangeModelsLst() ;
  2130. return -1 ;
  2131. } ;
  2132. if ((*pcuia)[IDF_OTHER] && m_csaOtherDataSecs[n].IsEmpty()) {
  2133. cserrmsg.Format(IDS_INFNoOtherStrError, m_csaModels[n]) ;
  2134. AfxMessageBox(cserrmsg, MB_ICONEXCLAMATION) ;
  2135. m_clbModels.SetCurSel(n) ;
  2136. OnSelchangeModelsLst() ;
  2137. return -1 ;
  2138. } ;
  2139. } ;
  2140. // All went well so...
  2141. return CPropertyPage::OnWizardNext();
  2142. }
  2143. LRESULT CINFWizDataSections::OnWizardBack()
  2144. {
  2145. // This works because the same thing needs to be done for both
  2146. // OnWizardNext() and OnWizardBack(). In addition,
  2147. // CPropertyPage::OnWizardNext() and CPropertyPage::OnWizardBack() just
  2148. // return 0.
  2149. return OnWizardNext() ;
  2150. }
  2151. void CINFWizDataSections::OnSelchangeModelsLst()
  2152. {
  2153. // If there was a previous model selection, save its data section flags.
  2154. // Otherwise, enable the install section check boxes.
  2155. if (m_nCurModelIdx != -1) {
  2156. UpdateData(TRUE) ;
  2157. CUIntArray* pcuia = (CUIntArray*) m_coaStdDataSecs[m_nCurModelIdx] ;
  2158. (*pcuia)[IDF_UNI] = (unsigned) m_bUnidrv ;
  2159. (*pcuia)[IDF_UNIBIDI] = (unsigned) m_bUnidrvBidi ;
  2160. (*pcuia)[IDF_PSCR] = (unsigned) m_bPscript ;
  2161. if ((*pcuia)[IDF_OTHER] = (unsigned) m_bOther)
  2162. m_csaOtherDataSecs[m_nCurModelIdx] = m_csOtherSections ;
  2163. } else {
  2164. for (int n = IDC_UnidrvChk ; n <= IDC_OtherChk ; n++)
  2165. GetDlgItem(n)->EnableWindow(TRUE) ;
  2166. } ;
  2167. // Save the index for the currently selected model. Then set the check
  2168. // boxes based on the flags for the specified model.
  2169. m_nCurModelIdx = m_clbModels.GetCurSel() ;
  2170. CUIntArray* pcuia = (CUIntArray*) m_coaStdDataSecs[m_nCurModelIdx] ;
  2171. m_bUnidrv = (BOOL) ((*pcuia)[IDF_UNI]) ;
  2172. m_bUnidrvBidi = (BOOL) ((*pcuia)[IDF_UNIBIDI]) ;
  2173. m_bPscript = (BOOL) ((*pcuia)[IDF_PSCR]) ;
  2174. if (m_bOther = (BOOL) ((*pcuia)[IDF_OTHER]))
  2175. m_csOtherSections = m_csaOtherDataSecs[m_nCurModelIdx] ;
  2176. else
  2177. m_csOtherSections = csEmpty ;
  2178. GetDlgItem(IDC_OtherBox)->EnableWindow(m_bOther) ;
  2179. UpdateData(FALSE) ;
  2180. }
  2181. void CINFWizDataSections::OnOtherChk()
  2182. {
  2183. // Enable or disable the Other sections edit box based on the new state of
  2184. // the Other check box.
  2185. UpdateData(TRUE) ;
  2186. GetDlgItem(IDC_OtherBox)->EnableWindow(m_bOther) ;
  2187. // If the Other check box was just checked, move the focus to the Other box.
  2188. if (m_bOther)
  2189. GetDlgItem(IDC_OtherBox)->SetFocus() ;
  2190. }
  2191. void CINFWizDataSections::OnPscriptChk()
  2192. {
  2193. // If the PostScript checkbox is checked, the Unidrv boxes must be
  2194. // unchecked.
  2195. UpdateData(TRUE) ;
  2196. if (m_bPscript) {
  2197. m_bUnidrvBidi = m_bUnidrv = FALSE ;
  2198. UpdateData(FALSE) ;
  2199. }
  2200. }
  2201. void CINFWizDataSections::OnUnidrvBidiChk()
  2202. {
  2203. // If the UNIDRV_BIDI box is checked, the UNIDRV and PostScript flags must
  2204. // be unchecked.
  2205. UpdateData(TRUE) ;
  2206. if (m_bUnidrvBidi) {
  2207. m_bPscript = m_bUnidrv = FALSE ;
  2208. UpdateData(FALSE) ;
  2209. }
  2210. }
  2211. void CINFWizDataSections::OnUnidrvChk()
  2212. {
  2213. // If the UNIDRV box is checked, the UNIDRV_BIDI and PostScript flags must
  2214. // be unchecked.
  2215. UpdateData(TRUE) ;
  2216. if (m_bUnidrv) {
  2217. m_bPscript = m_bUnidrvBidi = FALSE ;
  2218. UpdateData(FALSE) ;
  2219. }
  2220. }
  2221. void CINFWizDataSections::BiDiDataChanged()
  2222. {
  2223. // Do nothing if this page has not be initialized yet. In addition, do
  2224. // nothing if the selected models may have changed or a reinit has been
  2225. // request. These cases are taken care of in OnSetActive(). In additon,
  2226. // it allows this routine to know that the model data in this page are in
  2227. // the same order as the data in the BiDi page().
  2228. if (!m_bInitialized || m_bReInitWData || m_bSelChanged)
  2229. return ;
  2230. // Loop through the data for each selected model and make sure it agrees
  2231. // as much as possible with the current BiDi settings.
  2232. CUIntArray* pcuia ;
  2233. for (int n = 0 ; n < m_coaStdDataSecs.GetSize() ; n++) {
  2234. pcuia = (CUIntArray*) m_coaStdDataSecs[n] ;
  2235. // If the model's BiDi flag is set, make sure it is set here and that
  2236. // its Unidriv and PScript flags are clear.
  2237. if (m_pciwParent->m_ciwbd.m_cuaBiDiFlags[n]) {
  2238. (*pcuia)[IDF_UNIBIDI] = 1 ;
  2239. (*pcuia)[IDF_UNI] = (*pcuia)[IDF_PSCR] = 0 ;
  2240. // Otherwise, clear the BiDi flag. Then set the Unidrv flag if the
  2241. // PScript flag is clear.
  2242. } else {
  2243. (*pcuia)[IDF_UNIBIDI] = 0 ;
  2244. if ((*pcuia)[IDF_PSCR] == 0)
  2245. (*pcuia)[IDF_UNI] = 1 ;
  2246. } ;
  2247. } ;
  2248. // Reinitialize the controls on the page.
  2249. InitPageControls() ;
  2250. }
  2251. /////////////////////////////////////////////////////////////////////////////
  2252. // CINFWizExtraFiles property page
  2253. IMPLEMENT_DYNCREATE(CINFWizExtraFiles, CPropertyPage)
  2254. CINFWizExtraFiles::CINFWizExtraFiles() : CPropertyPage(CINFWizExtraFiles::IDD)
  2255. {
  2256. //{{AFX_DATA_INIT(CINFWizExtraFiles)
  2257. //}}AFX_DATA_INIT
  2258. m_bInitialized = m_bReInitWData = m_bSelChanged = false ;
  2259. m_nCurModelIdx = -1 ;
  2260. }
  2261. CINFWizExtraFiles::~CINFWizExtraFiles()
  2262. {
  2263. // Delete the string arrays referenced in m_coaExtraFSArrays.
  2264. CStringArray* pcsa ;
  2265. for (int n = 0 ; n < m_coaExtraFSArrays.GetSize() ; n++) {
  2266. pcsa = (CStringArray*) m_coaExtraFSArrays[n] ;
  2267. delete pcsa ;
  2268. } ;
  2269. }
  2270. void CINFWizExtraFiles::DoDataExchange(CDataExchange* pDX)
  2271. {
  2272. CPropertyPage::DoDataExchange(pDX);
  2273. //{{AFX_DATA_MAP(CINFWizExtraFiles)
  2274. DDX_Control(pDX, IDC_ExtraFSpecsLst, m_cfelcFSpecsLst);
  2275. DDX_Control(pDX, IDC_ModelLst, m_clbModels);
  2276. DDX_Control(pDX, IDC_BrowsBtn, m_cbBrowse);
  2277. //}}AFX_DATA_MAP
  2278. }
  2279. void CINFWizExtraFiles::ModelChangeFixups(unsigned unummodelssel,
  2280. CStringArray& csamodels,
  2281. CStringArray& csamodelslast)
  2282. {
  2283. // Do nothing if the page has not been initialized yet.
  2284. if (!m_bInitialized)
  2285. return ;
  2286. // See ModelChangeFixupsListListPage() for more information.
  2287. ModelChangeFixupsListListPage(unummodelssel, csamodels, csamodelslast,
  2288. m_cfelcFSpecsLst, m_coaExtraFSArrays,
  2289. m_nCurModelIdx, &m_cbBrowse, m_clbModels,
  2290. m_bReInitWData) ;
  2291. }
  2292. BEGIN_MESSAGE_MAP(CINFWizExtraFiles, CPropertyPage)
  2293. //{{AFX_MSG_MAP(CINFWizExtraFiles)
  2294. ON_LBN_SELCHANGE(IDC_ModelLst, OnSelchangeModelLst)
  2295. ON_BN_CLICKED(IDC_BrowsBtn, OnBrowsBtn)
  2296. //}}AFX_MSG_MAP
  2297. END_MESSAGE_MAP()
  2298. /////////////////////////////////////////////////////////////////////////////
  2299. // CINFWizExtraFiles message handlers
  2300. BOOL CINFWizExtraFiles::OnSetActive()
  2301. {
  2302. // Get the list of models to load into the main list box.
  2303. CStringArray& csamodels = m_pciwParent->GetINFModels() ;
  2304. // Nothing else need be done if this page has been initialized already
  2305. // and it is not being asked to reinitialize the page... That is,
  2306. // except for possibly needing to pick up any selected model changes
  2307. // that were made.
  2308. if (m_bInitialized && !m_bReInitWData) {
  2309. if (m_bSelChanged) {
  2310. ModelChangeFixups(m_pciwParent->GetINFModsSelCount(), csamodels,
  2311. m_pciwParent->GetINFModelsLst()) ;
  2312. m_bSelChanged = false ;
  2313. } ;
  2314. return CPropertyPage::OnSetActive() ;
  2315. } ;
  2316. // Pick up selected model changes when reinitializing
  2317. if (m_bReInitWData) {
  2318. ModelChangeFixups(m_pciwParent->GetINFModsSelCount(), csamodels,
  2319. m_pciwParent->GetINFModelsLst()) ;
  2320. m_bSelChanged = false ;
  2321. } ;
  2322. // See InitListListPage() for more details.
  2323. InitListListPage(m_clbModels, m_bInitialized, m_pciwParent,
  2324. m_coaExtraFSArrays, m_cfelcFSpecsLst,
  2325. IDS_INFExFilesColLab, csamodels, m_bReInitWData,
  2326. m_nCurModelIdx, 256, 0) ;
  2327. return CPropertyPage::OnSetActive() ;
  2328. }
  2329. void CINFWizExtraFiles::OnSelchangeModelLst()
  2330. {
  2331. SelChangedListListPage(m_clbModels, m_bInitialized, m_coaExtraFSArrays,
  2332. m_cfelcFSpecsLst, &m_cbBrowse, m_nCurModelIdx) ;
  2333. }
  2334. void CINFWizExtraFiles::OnBrowsBtn()
  2335. {
  2336. // See OnBrowseListListPage() for more information.
  2337. OnBrowseListListPage(m_cfelcFSpecsLst, IDS_CommonExtraFile) ;
  2338. }
  2339. LRESULT CINFWizExtraFiles::OnWizardNext()
  2340. {
  2341. // Do nothing if the page has not been initialized yet.
  2342. if (!m_bInitialized)
  2343. return -1 ;
  2344. // See OnWizNextListListPage() for more information.
  2345. OnWizNextListListPage(m_nCurModelIdx, m_cfelcFSpecsLst, m_coaExtraFSArrays);
  2346. return CPropertyPage::OnWizardNext() ;
  2347. }
  2348. LRESULT CINFWizExtraFiles::OnWizardBack()
  2349. {
  2350. // This works because the same thing needs to be done for both
  2351. // OnWizardNext() and OnWizardBack(). In addition,
  2352. // CPropertyPage::OnWizardNext() and CPropertyPage::OnWizardBack() just
  2353. // return 0.
  2354. return OnWizardNext() ;
  2355. }
  2356. /////////////////////////////////////////////////////////////////////////////
  2357. // CINFWizMfgName property page
  2358. IMPLEMENT_DYNCREATE(CINFWizMfgName, CPropertyPage)
  2359. CINFWizMfgName::CINFWizMfgName() : CPropertyPage(CINFWizMfgName::IDD)
  2360. {
  2361. //{{AFX_DATA_INIT(CINFWizMfgName)
  2362. m_csMfgName = csEmpty;
  2363. m_csMfgAbbrev = csEmpty;
  2364. //}}AFX_DATA_INIT
  2365. m_bInitialized = m_bReInitWData = false ;
  2366. }
  2367. CINFWizMfgName::~CINFWizMfgName()
  2368. {
  2369. }
  2370. void CINFWizMfgName::DoDataExchange(CDataExchange* pDX)
  2371. {
  2372. CPropertyPage::DoDataExchange(pDX);
  2373. //{{AFX_DATA_MAP(CINFWizMfgName)
  2374. DDX_Control(pDX, IDC_ProviderBox, m_ceMfgAbbrev);
  2375. DDX_Control(pDX, IDC_ManufacturerBox, m_ceMfgName);
  2376. DDX_Text(pDX, IDC_ManufacturerBox, m_csMfgName);
  2377. DDV_MaxChars(pDX, m_csMfgName, 64);
  2378. DDX_Text(pDX, IDC_ProviderBox, m_csMfgAbbrev);
  2379. DDV_MaxChars(pDX, m_csMfgAbbrev, 2);
  2380. //}}AFX_DATA_MAP
  2381. }
  2382. BEGIN_MESSAGE_MAP(CINFWizMfgName, CPropertyPage)
  2383. //{{AFX_MSG_MAP(CINFWizMfgName)
  2384. // NOTE: the ClassWizard will add message map macros here
  2385. //}}AFX_MSG_MAP
  2386. END_MESSAGE_MAP()
  2387. /////////////////////////////////////////////////////////////////////////////
  2388. // CINFWizMfgName message handlers
  2389. BOOL CINFWizMfgName::OnSetActive()
  2390. {
  2391. // Do nothing if the page has been initialized already and it is not being
  2392. // asked to reinitialize itself.
  2393. CStringArray csagpd ; // RAID 0001 ; move to head from body
  2394. if (m_bInitialized && !m_bReInitWData)
  2395. return CPropertyPage::OnSetActive() ;
  2396. // Most of the work needed to initialize this page is only needed when it
  2397. // is NOT being asked to REinitialized itself.
  2398. if (!m_bReInitWData) {
  2399. // Find the class instance associated with the first selected model.
  2400. CStringArray& csamodels = m_pciwParent->GetINFModels() ;
  2401. unsigned unummodels = m_pciwParent->GetModelCount() ;
  2402. if(!m_pciwParent->m_pcgc){ //RAID 0001
  2403. for (unsigned u = 0 ; u < unummodels ; u++) {
  2404. if (csamodels[0] == m_pciwParent->GetModel(u).Name())
  2405. break ;
  2406. } ;
  2407. ASSERT(u < unummodels) ;
  2408. LoadFile(m_pciwParent->GetModel(u).FileName(), csagpd) ;
  2409. }
  2410. else
  2411. LoadFile(m_pciwParent->m_pcgc->GetPathName(), csagpd) ;
  2412. //END RAID 0001
  2413. // Open/Read/Close the model's GPD file.
  2414. // Scan the file for and isolate the ModelName entry.
  2415. int numlines = (int)csagpd.GetSize() ;
  2416. CString csmodelname(_T("ModelName")) ;
  2417. CString cscurline ;
  2418. int nloc ;
  2419. for (int n = 0 ; n < numlines ; n++) {
  2420. if ((nloc = csagpd[n].Find(csmodelname)) >= 0) {
  2421. csmodelname = csagpd[n].Mid(csmodelname.GetLength() + nloc) ;
  2422. if ((nloc = csmodelname.Find(_T('"'))) >= 0) {
  2423. csmodelname = csmodelname.Mid(nloc + 1) ;
  2424. if ((nloc = csmodelname.Find(_T('"'))) >= 0)
  2425. csmodelname = csmodelname.Left(nloc) ;
  2426. } else {
  2427. if (csmodelname[0] == _T(':'))
  2428. csmodelname = csmodelname.Mid(1) ;
  2429. } ;
  2430. csmodelname.TrimLeft() ;
  2431. csmodelname.TrimRight() ;
  2432. break ;
  2433. } ;
  2434. } ;
  2435. // If the ModelName entry was found...
  2436. if (n < numlines && !csmodelname.IsEmpty()) {
  2437. // Use the first space terminated value in the ModelName entry for
  2438. // the manufacturer's name.
  2439. if ((nloc = csmodelname.Find(_T(' '))) >= 0)
  2440. m_csMfgName = csmodelname.Left(nloc) ;
  2441. else
  2442. m_csMfgName = csmodelname ;
  2443. // Use the first two letters of the ModelName entry for the
  2444. // provider's "name".
  2445. m_csMfgAbbrev = csmodelname.Left(2) ;
  2446. m_csMfgAbbrev.MakeUpper() ;
  2447. // Load the manufacturer and provider names into the edit boxes on
  2448. // this page.
  2449. UpdateData(false) ;
  2450. } ;
  2451. // When reinitializing, the member variables associated with the controls
  2452. // are already set so just use them.
  2453. } else
  2454. UpdateData(false) ;
  2455. // Set focus to first control, set initialization flag, and return.
  2456. m_ceMfgName.SetFocus() ;
  2457. m_bInitialized = true ;
  2458. m_bReInitWData = false ; // Reinit (if needed) is done now on this page
  2459. return CPropertyPage::OnSetActive();
  2460. }
  2461. LRESULT CINFWizMfgName::OnWizardNext()
  2462. {
  2463. // Get the values for the manufacturer and provider.
  2464. UpdateData(true) ;
  2465. // Complain if either field is blank and do not move on to the next page.
  2466. // Make sure the abbreviation is 2 characters long, too.
  2467. m_csMfgName.TrimLeft() ;
  2468. m_csMfgName.TrimRight() ;
  2469. m_csMfgAbbrev.TrimLeft() ;
  2470. m_csMfgAbbrev.TrimRight() ;
  2471. CString csmsg ;
  2472. if (m_csMfgName.IsEmpty()) {
  2473. m_ceMfgName.SetFocus() ;
  2474. csmsg.LoadString(IDS_NoMfgError) ;
  2475. AfxMessageBox(csmsg, MB_ICONEXCLAMATION) ;
  2476. return -1 ;
  2477. } ;
  2478. if (m_csMfgAbbrev.IsEmpty() || m_csMfgAbbrev.GetLength() != 2) {
  2479. m_ceMfgAbbrev.SetFocus() ;
  2480. csmsg.LoadString(IDS_NoMfgAbbrevError) ;
  2481. AfxMessageBox(csmsg, MB_ICONEXCLAMATION) ;
  2482. return -1 ;
  2483. } ;
  2484. // All appears to be well so...
  2485. return CPropertyPage::OnWizardNext() ;
  2486. }
  2487. LRESULT CINFWizMfgName::OnWizardBack()
  2488. {
  2489. // This works because the same thing needs to be done for both
  2490. // OnWizardNext() and OnWizardBack(). In addition,
  2491. // CPropertyPage::OnWizardNext() and CPropertyPage::OnWizardBack() just
  2492. // return 0.
  2493. return OnWizardNext() ;
  2494. }
  2495. /////////////////////////////////////////////////////////////////////////////
  2496. // CINFWizNonStdElts property page
  2497. IMPLEMENT_DYNCREATE(CINFWizNonStdElts, CPropertyPage)
  2498. CINFWizNonStdElts::CINFWizNonStdElts() : CPropertyPage(CINFWizNonStdElts::IDD)
  2499. {
  2500. //{{AFX_DATA_INIT(CINFWizNonStdElts)
  2501. //}}AFX_DATA_INIT
  2502. m_bInitialized = m_bReInitWData = m_bNewSectionAdded = false ;
  2503. m_nCurSectionIdx = -1 ;
  2504. }
  2505. CINFWizNonStdElts::~CINFWizNonStdElts()
  2506. {
  2507. // Delete the string arrays referenced in m_coaSectionArrays.
  2508. CStringArray* pcsa ;
  2509. for (int n = 0 ; n < m_coaSectionArrays.GetSize() ; n++) {
  2510. pcsa = (CStringArray*) m_coaSectionArrays[n] ;
  2511. delete pcsa ;
  2512. } ;
  2513. }
  2514. void CINFWizNonStdElts::DoDataExchange(CDataExchange* pDX)
  2515. {
  2516. CPropertyPage::DoDataExchange(pDX);
  2517. //{{AFX_DATA_MAP(CINFWizNonStdElts)
  2518. DDX_Control(pDX, IDC_NewSectionBtn, m_ceNewSection);
  2519. DDX_Control(pDX, IDC_KeyValueLst, m_felcKeyValueLst);
  2520. DDX_Control(pDX, IDC_SectionLst, m_clbSections);
  2521. //}}AFX_DATA_MAP
  2522. }
  2523. BEGIN_MESSAGE_MAP(CINFWizNonStdElts, CPropertyPage)
  2524. //{{AFX_MSG_MAP(CINFWizNonStdElts)
  2525. ON_LBN_SELCHANGE(IDC_SectionLst, OnSelchangeSectionLst)
  2526. ON_BN_CLICKED(IDC_NewSectionBtn, OnNewSectionBtn)
  2527. //}}AFX_MSG_MAP
  2528. END_MESSAGE_MAP()
  2529. /////////////////////////////////////////////////////////////////////////////
  2530. // CINFWizNonStdElts message handlers
  2531. BOOL CINFWizNonStdElts::OnSetActive()
  2532. {
  2533. // Build an array of valid section names.
  2534. if (!m_bInitialized) {
  2535. m_csaSections.Add(_T("[ControlFlags]")) ;
  2536. m_csaSections.Add(_T("[DestinationDirs]")) ;
  2537. m_csaSections.Add(_T("[Device]")) ;
  2538. m_csaSections.Add(_T("[Install]")) ;
  2539. m_csaSections.Add(_T("[Manufacturer]")) ;
  2540. m_csaSections.Add(_T("[SourceDisksFiles]")) ;
  2541. m_csaSections.Add(_T("[SourceDisksNames]")) ;
  2542. m_csaSections.Add(_T("[Strings]")) ;
  2543. } ;
  2544. // See InitListListPage() for more details.
  2545. InitListListPage(m_clbSections, m_bInitialized, m_pciwParent,
  2546. m_coaSectionArrays, m_felcKeyValueLst, IDS_NonStdColLab,
  2547. m_csaSections, m_bReInitWData, m_nCurSectionIdx, 256, 0) ;
  2548. m_bNewSectionAdded = false ;
  2549. return CPropertyPage::OnSetActive() ;
  2550. }
  2551. void CINFWizNonStdElts::OnSelchangeSectionLst()
  2552. {
  2553. SelChangedListListPage(m_clbSections, m_bInitialized, m_coaSectionArrays,
  2554. m_felcKeyValueLst, NULL, m_nCurSectionIdx) ;
  2555. }
  2556. void CINFWizNonStdElts::OnNewSectionBtn()
  2557. {
  2558. // Do nothing if the page has not been initialized yet.
  2559. if (!m_bInitialized)
  2560. return ;
  2561. // Prompt the user for a new section name. Return if the user cancels.
  2562. CNewINFSection cnis ;
  2563. if (cnis.DoModal() == IDCANCEL)
  2564. return ;
  2565. // Get the new section name and add brackets if necessary.
  2566. CString csnewsec = cnis.m_csNewSection ;
  2567. csnewsec.TrimLeft() ;
  2568. csnewsec.TrimRight() ;
  2569. if (csnewsec[0] != _T('['))
  2570. csnewsec = csLBrack + csnewsec ;
  2571. if (csnewsec.Right(1) != csRBrack)
  2572. csnewsec += csRBrack ;
  2573. // Add a new string array to hold the data for the new section.
  2574. CStringArray* pcsa = new CStringArray ;
  2575. int nelts = m_felcKeyValueLst.GetItemCount() ;
  2576. pcsa->SetSize(nelts) ;
  2577. for (int n = 0 ; n < nelts ; n++)
  2578. pcsa->SetAt(n, csEmpty) ;
  2579. m_coaSectionArrays.Add((CObject*) pcsa) ;
  2580. // Add the new section to the sections array. Then, add the new section to
  2581. // the sections list box and try to select this item and make it visible.
  2582. m_csaSections.Add(csnewsec) ;
  2583. int nidx = m_clbSections.AddString(csnewsec) ;
  2584. m_clbSections.SetCurSel(nidx) ;
  2585. OnSelchangeSectionLst() ;
  2586. // Note that a new section was added during this activation of the page.
  2587. m_bNewSectionAdded = true ;
  2588. }
  2589. LRESULT CINFWizNonStdElts::OnWizardNext()
  2590. {
  2591. // Do nothing if the page has not been initialized yet.
  2592. if (!m_bInitialized)
  2593. return -1 ;
  2594. // See OnWizNextListListPage() for more information.
  2595. OnWizNextListListPage(m_nCurSectionIdx, m_felcKeyValueLst,
  2596. m_coaSectionArrays) ;
  2597. // Make sure the "section used in INF file flags" array is correctly sized.
  2598. m_cuaSecUsed.SetSize(m_csaSections.GetSize()) ;
  2599. // If this is not the first time this page has been used, any changes made
  2600. // could affect the data managed by some of the other pages. Make a call
  2601. // to fixup that data when needed.
  2602. if (m_bNewSectionAdded)
  2603. m_pciwParent->NonStdSecsChanged() ;
  2604. return CPropertyPage::OnWizardNext() ;
  2605. }
  2606. LRESULT CINFWizNonStdElts::OnWizardBack()
  2607. {
  2608. // This works because the same thing needs to be done for both
  2609. // OnWizardNext() and OnWizardBack(). In addition,
  2610. // CPropertyPage::OnWizardNext() and CPropertyPage::OnWizardBack() just
  2611. // return 0.
  2612. return OnWizardNext() ;
  2613. }
  2614. /////////////////////////////////////////////////////////////////////////////
  2615. // CINFWizNonStdModelSecs property page
  2616. IMPLEMENT_DYNCREATE(CINFWizNonStdModelSecs, CPropertyPage)
  2617. CINFWizNonStdModelSecs::CINFWizNonStdModelSecs() : CPropertyPage(CINFWizNonStdModelSecs::IDD)
  2618. {
  2619. //{{AFX_DATA_INIT(CINFWizNonStdModelSecs)
  2620. // NOTE: the ClassWizard will add member initialization here
  2621. //}}AFX_DATA_INIT
  2622. m_bInitialized = m_bReInitWData = false ;
  2623. m_nCurSectionIdx = -1 ;
  2624. }
  2625. CINFWizNonStdModelSecs::~CINFWizNonStdModelSecs()
  2626. {
  2627. // Delete the string arrays referenced in m_coaModelsNeedingSecs.
  2628. CStringArray* pcsa ;
  2629. for (int n = 0 ; n < m_coaModelsNeedingSecs.GetSize() ; n++) {
  2630. pcsa = (CStringArray*) m_coaModelsNeedingSecs[n] ;
  2631. delete pcsa ;
  2632. } ;
  2633. }
  2634. void CINFWizNonStdModelSecs::DoDataExchange(CDataExchange* pDX)
  2635. {
  2636. CPropertyPage::DoDataExchange(pDX);
  2637. //{{AFX_DATA_MAP(CINFWizNonStdModelSecs)
  2638. DDX_Control(pDX, IDC_ModelSectionLst, m_cfelcModelsLst);
  2639. DDX_Control(pDX, IDC_SectionLst, m_clbSectionsLst);
  2640. //}}AFX_DATA_MAP
  2641. }
  2642. BEGIN_MESSAGE_MAP(CINFWizNonStdModelSecs, CPropertyPage)
  2643. //{{AFX_MSG_MAP(CINFWizNonStdModelSecs)
  2644. ON_LBN_SELCHANGE(IDC_SectionLst, OnSelchangeSectionLst)
  2645. //}}AFX_MSG_MAP
  2646. END_MESSAGE_MAP()
  2647. /////////////////////////////////////////////////////////////////////////////
  2648. // CINFWizNonStdModelSecs message handlers
  2649. BOOL CINFWizNonStdModelSecs::OnSetActive()
  2650. {
  2651. // Turn off the finish button.
  2652. m_pciwParent->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT) ;
  2653. // Just perform the default actions if nothing special needs to be done.
  2654. if (m_bInitialized && (!m_bReInitWData) && (!m_bSelChanged))
  2655. return CPropertyPage::OnSetActive() ;
  2656. int n, n2, n3 ; // Looping variable
  2657. int numelts ; // Number of elements in an array
  2658. CStringArray* pcsa ; // Used to reference a sections models array
  2659. // Perform the first time initialization.
  2660. if (!m_bInitialized) {
  2661. // Get a copy of the nonstandard section names and the selected model
  2662. // names.
  2663. m_csaSections.Copy(m_pciwParent->m_ciwnse.m_csaSections) ;
  2664. m_csaModels.Copy(m_pciwParent->GetINFModels()) ;
  2665. // The following array is used to manage the models that need each
  2666. // section. Set its size to the same as the number of sections and
  2667. // load its elements with pointers to string arrays. Load the sections
  2668. // list box in the same loop.
  2669. numelts = (int) m_csaSections.GetSize() ;
  2670. m_coaModelsNeedingSecs.SetSize(numelts) ;
  2671. m_clbSectionsLst.ResetContent() ;
  2672. for (n = 0 ; n < numelts ; n++) {
  2673. pcsa = new CStringArray ;
  2674. pcsa->RemoveAll() ;
  2675. m_coaModelsNeedingSecs[n] = (CObArray*) pcsa ;
  2676. m_clbSectionsLst.AddString(m_csaSections[n]) ;
  2677. } ;
  2678. m_clbSectionsLst.SetFocus() ;
  2679. // Initialize and load the list control
  2680. InitModelsListCtl() ;
  2681. // Set init flag, reset other flags, and return whatever the base class
  2682. // function returns.
  2683. m_bInitialized = true ;
  2684. m_bReInitWData = m_bSelChanged = false ;
  2685. return CPropertyPage::OnSetActive() ;
  2686. } ;
  2687. // Either the selected models have changed or the wizard is being
  2688. // reinitialized if this point is reached. They are handled in similar
  2689. // ways.
  2690. //
  2691. // Begin by removing references to models that are no longer selected.
  2692. m_csaModels.RemoveAll() ;
  2693. m_csaModels.Copy(m_pciwParent->GetINFModels()) ;
  2694. int nummodels = (int) m_csaModels.GetSize() ;
  2695. numelts = (int) m_coaModelsNeedingSecs.GetSize() ;
  2696. for (n = 0 ; n < numelts ; n++) {
  2697. pcsa = (CStringArray*) m_coaModelsNeedingSecs[n] ;
  2698. for (n2 = (int) pcsa->GetSize() - 1 ; n2 >= 0 ; n2--) {
  2699. for (n3 = 0 ; n3 < nummodels ; n3++)
  2700. if ((*pcsa)[n2] == m_csaModels[n3])
  2701. break ;
  2702. if (n3 >= nummodels)
  2703. pcsa->RemoveAt(n2) ;
  2704. } ;
  2705. } ;
  2706. // Reinitialize the list control if the wizard has been reinitialized.
  2707. // Otherwise, the models may have changed so update that column of the
  2708. // list control.
  2709. if (m_bReInitWData)
  2710. InitModelsListCtl() ;
  2711. else
  2712. m_cfelcModelsLst.SetColumnData((CObArray*) &m_csaModels, 0) ;
  2713. // Update the sections information.
  2714. UpdateSectionData() ;
  2715. // Set init flag, reset other flags, and return whatever the base class
  2716. // function returns.
  2717. m_bInitialized = true ;
  2718. m_bReInitWData = m_bSelChanged = false ;
  2719. return CPropertyPage::OnSetActive() ;
  2720. }
  2721. void CINFWizNonStdModelSecs::OnSelchangeSectionLst()
  2722. {
  2723. // If there was a previous section selection, save the list of models that
  2724. // need it. Otherwise, enable the models list control.
  2725. if (m_nCurSectionIdx != -1)
  2726. SaveSectionModelInfo() ;
  2727. else
  2728. m_cfelcModelsLst.EnableWindow(TRUE) ;
  2729. // Save the index of the newly selected section and then use that index to
  2730. // get the array of selected models for the section.
  2731. m_nCurSectionIdx = m_clbSectionsLst.GetCurSel() ;
  2732. CStringArray* pcsa ;
  2733. pcsa = (CStringArray*) m_coaModelsNeedingSecs[m_nCurSectionIdx] ;
  2734. // Declare and size a new array that will be loaded with info on the
  2735. // selected models for the current section. Then load the string displayed
  2736. // in the list control for selected models.
  2737. CStringArray csaselmods ;
  2738. int numelts = (int) m_csaModels.GetSize() ;
  2739. csaselmods.SetSize(numelts) ;
  2740. CString csselstr ;
  2741. csselstr.LoadString(IDS_INF_NSMS_ToggleStr) ;
  2742. // Use the list of all models and the current selection's list of models to
  2743. // build an array with the selected string in the right spots so that this
  2744. // array can be loaded into the list control.
  2745. for (int n2 = 0 ; n2 < pcsa->GetSize() ; n2++)
  2746. for (int n = 0 ; n < numelts ; n++)
  2747. if ((*pcsa)[n2] == m_csaModels[n])
  2748. csaselmods[n] = csselstr ;
  2749. // Load array built above into the list control so that the user can see
  2750. // which models have been selected for the current section.
  2751. m_cfelcModelsLst.SetColumnData((CObArray*) &csaselmods, 1) ;
  2752. }
  2753. LRESULT CINFWizNonStdModelSecs::OnWizardNext()
  2754. {
  2755. // If there was a previous section selection, save the list of models that
  2756. // need it.
  2757. if (m_nCurSectionIdx != -1)
  2758. SaveSectionModelInfo() ;
  2759. return CPropertyPage::OnWizardNext();
  2760. }
  2761. LRESULT CINFWizNonStdModelSecs::OnWizardBack()
  2762. {
  2763. // This works because the same thing needs to be done for both
  2764. // OnWizardNext() and OnWizardBack(). In addition,
  2765. // CPropertyPage::OnWizardNext() and CPropertyPage::OnWizardBack() just
  2766. // return 0.
  2767. return OnWizardNext() ;
  2768. }
  2769. void CINFWizNonStdModelSecs::SaveSectionModelInfo()
  2770. {
  2771. // Get the selection data out of the list control.
  2772. CStringArray csaselmods ;
  2773. m_cfelcModelsLst.GetColumnData((CObArray*) &csaselmods, 1) ;
  2774. // Use the index of the selected section to get a list of its currently
  2775. // selected models. Remove the models in it because it will be refilled
  2776. // with new data later.
  2777. CStringArray* pcsa ;
  2778. pcsa = (CStringArray*) m_coaModelsNeedingSecs[m_nCurSectionIdx] ;
  2779. pcsa->RemoveAll() ;
  2780. // Add every selected model to the section's selected models array.
  2781. for (int n = 0 ; n < m_csaModels.GetSize() ; n++)
  2782. if (!csaselmods[n].IsEmpty())
  2783. pcsa->Add(m_csaModels[n]) ;
  2784. }
  2785. void CINFWizNonStdModelSecs::NonStdSecsChanged()
  2786. {
  2787. // Do nothing if this page has not be initialized yet. In addition, do
  2788. // nothing if the selected models may have changed or a reinit has been
  2789. // request. These cases are taken care of in OnSetActive().
  2790. if (!m_bInitialized || m_bReInitWData || m_bSelChanged)
  2791. return ;
  2792. // Update the section data to agree with any changes that may have been
  2793. // made.
  2794. UpdateSectionData() ;
  2795. }
  2796. void CINFWizNonStdModelSecs::UpdateSectionData()
  2797. {
  2798. // Get a copy of the latest nonstandard section.
  2799. int n, n2 ; // Looping variables
  2800. CStringArray csanewsections ;
  2801. csanewsections.Copy(m_pciwParent->m_ciwnse.m_csaSections) ;
  2802. // Allocate and size the flags arrays used to determine which sections are
  2803. // still in use.
  2804. int numelts = (int) m_csaSections.GetSize() ;
  2805. int newnumelts = (int) csanewsections.GetSize() ;
  2806. CUIntArray cuiaoldflags, cuianewflags ;
  2807. cuiaoldflags.SetSize(numelts) ;
  2808. for (n = 0 ; n < numelts ; n++)
  2809. cuiaoldflags[n] = 0 ;
  2810. cuianewflags.SetSize(newnumelts) ;
  2811. for (n = 0 ; n < newnumelts ; n++)
  2812. cuianewflags[n] = 0 ;
  2813. // Loop through the old & new models to see which of them are still in use.
  2814. for (n = 0 ; n < numelts ; n++)
  2815. for (n2 = 0 ; n2 < newnumelts ; n2++)
  2816. if (m_csaSections[n] == csanewsections[n2]) {
  2817. cuiaoldflags[n] = cuianewflags[n2] = 1 ;
  2818. break ;
  2819. } ;
  2820. // Remove the old sections and related data that are no longer needed.
  2821. CStringArray* pcsa ;
  2822. for (n = numelts - 1 ; n >= 0 ; n--)
  2823. if (cuiaoldflags[n] == 0) {
  2824. m_csaSections.RemoveAt(n) ;
  2825. pcsa = (CStringArray*) m_coaModelsNeedingSecs[n] ;
  2826. delete pcsa ;
  2827. m_coaModelsNeedingSecs.RemoveAt(n) ;
  2828. } ;
  2829. // Add the truly new sections to this page's array of section names and
  2830. // initialize all related section data for it.
  2831. for (n = n2 = 0 ; n < newnumelts ; n++) {
  2832. if (cuianewflags[n] == 1) {
  2833. n2++ ;
  2834. continue ;
  2835. } ;
  2836. m_csaSections.InsertAt(n2, csanewsections[n]) ;
  2837. pcsa = new CStringArray ;
  2838. m_coaModelsNeedingSecs.InsertAt(n2, (CObject*) pcsa) ;
  2839. } ;
  2840. // Clear the sections list box and reload it with the new sections data.
  2841. // Make sure that nothing is selected in the listbox and give it the focus.
  2842. m_clbSectionsLst.ResetContent() ;
  2843. for (n = 0, numelts = (int) m_csaSections.GetSize() ; n < numelts ; n++)
  2844. m_clbSectionsLst.AddString(m_csaSections[n]) ;
  2845. m_clbSectionsLst.SetCurSel(-1) ;
  2846. m_nCurSectionIdx = -1 ;
  2847. m_clbSectionsLst.SetFocus() ;
  2848. // Clear the selected models column in the list control and disable it.
  2849. CStringArray csa ;
  2850. csa.SetSize(m_csaModels.GetSize()) ;
  2851. m_cfelcModelsLst.SetColumnData((CObArray*) &csa, 1) ;
  2852. m_cfelcModelsLst.EnableWindow(FALSE) ;
  2853. }
  2854. void CINFWizNonStdModelSecs::InitModelsListCtl()
  2855. {
  2856. int numelts ; // Number of elements in an array
  2857. CString cstmp ;
  2858. // Initialize the list control
  2859. numelts = (int) m_csaModels.GetSize() ;
  2860. m_cfelcModelsLst.InitControl(LVS_EX_FULLROWSELECT, numelts, 2,
  2861. TF_HASTOGGLECOLUMNS+TF_CLICKONROW, 0,
  2862. MF_IGNOREINSDEL) ;
  2863. // Load the models column in the list control.
  2864. cstmp.LoadString(IDS_INFModelsColLab) ;
  2865. m_cfelcModelsLst.InitLoadColumn(0, cstmp, COMPUTECOLWIDTH, 25, false,
  2866. false, COLDATTYPE_STRING,
  2867. (CObArray*) &m_csaModels) ;
  2868. // Initialize the bidi column in the list control.
  2869. cstmp.LoadString(IDS_INFSecNeededColLab) ;
  2870. CStringArray csaempty ;
  2871. m_csToggleStr.LoadString(IDS_INF_NSMS_ToggleStr) ;
  2872. m_cfelcModelsLst.InitLoadColumn(1, cstmp, SETWIDTHTOREMAINDER, -25,
  2873. false, false, COLDATTYPE_TOGGLE,
  2874. (CObArray*) &csaempty, m_csToggleStr) ;
  2875. }
  2876. /////////////////////////////////////////////////////////////////////////////
  2877. // CINFWizSummary property page
  2878. IMPLEMENT_DYNCREATE(CINFWizSummary, CPropertyPage)
  2879. CINFWizSummary::CINFWizSummary() : CPropertyPage(CINFWizSummary::IDD)
  2880. {
  2881. //{{AFX_DATA_INIT(CINFWizSummary)
  2882. //}}AFX_DATA_INIT
  2883. m_bInitialized = m_bReInitWData = false ;
  2884. }
  2885. CINFWizSummary::~CINFWizSummary()
  2886. {
  2887. }
  2888. void CINFWizSummary::DoDataExchange(CDataExchange* pDX)
  2889. {
  2890. CPropertyPage::DoDataExchange(pDX);
  2891. //{{AFX_DATA_MAP(CINFWizSummary)
  2892. DDX_Control(pDX, IDC_SummaryBox, m_ceSummary);
  2893. //}}AFX_DATA_MAP
  2894. }
  2895. BEGIN_MESSAGE_MAP(CINFWizSummary, CPropertyPage)
  2896. //{{AFX_MSG_MAP(CINFWizSummary)
  2897. // NOTE: the ClassWizard will add message map macros here
  2898. //}}AFX_MSG_MAP
  2899. END_MESSAGE_MAP()
  2900. /////////////////////////////////////////////////////////////////////////////
  2901. // CINFWizSummary message handlers
  2902. BOOL CINFWizSummary::OnSetActive()
  2903. {
  2904. // Turn on the finish button.
  2905. m_pciwParent->SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH) ;
  2906. // Initialize the summary to empty.
  2907. CString cs, cs2, cs3, cs4, cssummary ;
  2908. cssummary = csEmpty ;
  2909. // Add the selected models to the summary
  2910. CStringArray& csamodels = m_pciwParent->GetINFModels() ;
  2911. cssummary.LoadString(IDS_ModelsSumTxt) ;
  2912. int nummodels = (int)csamodels.GetSize() ;
  2913. for (int n = 0 ; n < nummodels ; n++) {
  2914. cs.Format("\t%s\r\n", csamodels[n]) ;
  2915. cssummary += cs ;
  2916. } ;
  2917. // Add PnP ID info to the summary
  2918. cs.LoadString(IDS_PnPIDSumTxt) ;
  2919. cssummary += cs ;
  2920. bool bfoundone = false ;
  2921. for (n = 0 ; n < nummodels ; n++) {
  2922. if (!m_pciwParent->m_ciwgpi.m_csaModelIDs[n].IsEmpty()) {
  2923. cs.Format("\t%s: %s\r\n", csamodels[n],
  2924. m_pciwParent->m_ciwgpi.m_csaModelIDs[n]) ;
  2925. cssummary += cs ;
  2926. bfoundone = true ;
  2927. } ;
  2928. } ;
  2929. if (!bfoundone) {
  2930. cs.LoadString(IDS_NoneSumTxt) ;
  2931. cssummary += cs ;
  2932. } ;
  2933. // Add BIDI info to the summary
  2934. cs.LoadString(IDS_BIDISumTxt) ;
  2935. cssummary += cs ;
  2936. bfoundone = false ;
  2937. for (n = 0 ; n < nummodels ; n++) {
  2938. if (m_pciwParent->m_ciwbd.m_cuaBiDiFlags[n]) {
  2939. cs.Format("\t%s\r\n", csamodels[n]) ;
  2940. cssummary += cs ;
  2941. bfoundone = true ;
  2942. } ;
  2943. } ;
  2944. if (!bfoundone) {
  2945. cs.LoadString(IDS_NoneSumTxt) ;
  2946. cssummary += cs ;
  2947. } ;
  2948. // Add the ICM profiles info to the summary.
  2949. cs.LoadString(IDS_ICMSumTxt) ;
  2950. cssummary += cs ;
  2951. bfoundone = false ;
  2952. CStringArray* pcsa ;
  2953. int n2, numstrs ;
  2954. for (n = 0 ; n < nummodels ; n++) {
  2955. pcsa = (CStringArray*) m_pciwParent->m_ciwip.m_coaProfileArrays[n] ;
  2956. if ((numstrs = (int)pcsa->GetSize()) > 0) {
  2957. cs.Format("\t%s\r\n", csamodels[n]) ;
  2958. cssummary += cs ;
  2959. bfoundone = true ;
  2960. for (n2 = 0 ; n2 < numstrs ; n2++) {
  2961. cs.Format("\t\t%s\r\n", pcsa->GetAt(n2)) ;
  2962. cssummary += cs ;
  2963. } ;
  2964. } ;
  2965. } ;
  2966. if (!bfoundone) {
  2967. cs.LoadString(IDS_NoneSumTxt) ;
  2968. cssummary += cs ;
  2969. } ;
  2970. // Add the include files info to the summary
  2971. cs.LoadString(IDS_IncFilesSumTxt) ;
  2972. cssummary += cs ;
  2973. for (n = 0 ; n < nummodels ; n++) {
  2974. cs.Format("\t%s\r\n\t\t%s\r\n", csamodels[n],
  2975. m_pciwParent->m_ciwif.m_csaIncFiles[n]) ;
  2976. cssummary += cs ;
  2977. } ;
  2978. // Add the install sections info to the summary
  2979. cs.LoadString(IDS_InstSecsSumTxt) ;
  2980. cssummary += cs ;
  2981. CUIntArray* pcuia ;
  2982. int nid ;
  2983. for (n = 0 ; n < nummodels ; n++) {
  2984. cs.Format("\t%s\r\n", csamodels[n]) ;
  2985. cssummary += cs ;
  2986. pcuia = (CUIntArray*) m_pciwParent->m_ciwis.m_coaStdInstSecs[n] ;
  2987. cs = cs3 = cs4 = csEmpty ;
  2988. cs = "\t\t" ;
  2989. nid = IDS_InstSecUni ;
  2990. for (n2 = 0 ; n2 < NUMINSTSECFLAGS - 1 ; n2++, nid++)
  2991. if ((*pcuia)[n2]) {
  2992. cs2.LoadString(nid) ;
  2993. cs4.Format("%s%s", cs3, cs2) ;
  2994. cs += cs4 ;
  2995. cs3 = _T(", ") ;
  2996. } ;
  2997. if ((*pcuia)[ISF_OTHER]) {
  2998. cs4.Format("%s%s", cs3,
  2999. m_pciwParent->m_ciwis.m_csaOtherInstSecs[n]) ;
  3000. cs += cs4 ;
  3001. } ;
  3002. cssummary += cs + csCRLF ;
  3003. } ;
  3004. // Add the data sections info to the summary
  3005. cs.LoadString(IDS_DataSecsSumTxt) ;
  3006. cssummary += cs ;
  3007. for (n = 0 ; n < nummodels ; n++) {
  3008. cs.Format("\t%s\r\n", csamodels[n]) ;
  3009. cssummary += cs ;
  3010. pcuia = (CUIntArray*) m_pciwParent->m_ciwds.m_coaStdDataSecs[n] ;
  3011. cs = cs3 = cs4 = csEmpty ;
  3012. cs = "\t\t" ;
  3013. nid = IDS_DataSecUni ;
  3014. for (n2 = 0 ; n2 < NUMDATASECFLAGS - 1 ; n2++, nid++)
  3015. if ((*pcuia)[n2]) {
  3016. cs2.LoadString(nid) ;
  3017. cs4.Format("%s%s", cs3, cs2) ;
  3018. cs += cs4 ;
  3019. cs3 = _T(", ") ;
  3020. } ;
  3021. if ((*pcuia)[IDF_OTHER]) {
  3022. cs4.Format("%s%s", cs3,
  3023. m_pciwParent->m_ciwds.m_csaOtherDataSecs[n]) ;
  3024. cs += cs4 ;
  3025. } ;
  3026. cssummary += cs + csCRLF ;
  3027. } ;
  3028. // Add the nonstandard files info to the summary
  3029. cs.LoadString(IDS_NonStdFilesSumTxt) ;
  3030. cssummary += cs ;
  3031. bfoundone = false ;
  3032. for (n = 0 ; n < nummodels ; n++) {
  3033. pcsa = (CStringArray*) m_pciwParent->m_ciwef.m_coaExtraFSArrays[n] ;
  3034. if ((numstrs = (int)pcsa->GetSize()) > 0) {
  3035. cs.Format("\t%s\r\n", csamodels[n]) ;
  3036. cssummary += cs ;
  3037. bfoundone = true ;
  3038. for (n2 = 0 ; n2 < numstrs ; n2++) {
  3039. cs.Format("\t\t%s\r\n", pcsa->GetAt(n2)) ;
  3040. cssummary += cs ;
  3041. } ;
  3042. } ;
  3043. } ;
  3044. if (!bfoundone) {
  3045. cs.LoadString(IDS_NoneSumTxt) ;
  3046. cssummary += cs ;
  3047. } ;
  3048. // Add the manufacturer and provider info to the summary
  3049. cs.Format(IDS_MfgSumTxt, m_pciwParent->m_ciwmn.m_csMfgName) ;
  3050. cssummary += cs ;
  3051. cs.Format(IDS_ProvSumTxt, m_pciwParent->m_ciwmn.m_csMfgAbbrev) ;
  3052. cssummary += cs ;
  3053. // Add the nonstandard sections info to the summary
  3054. cs.LoadString(IDS_NonStdSecSumTxt) ;
  3055. cssummary += cs ;
  3056. bfoundone = false ;
  3057. CStringArray& csasections = m_pciwParent->m_ciwnse.m_csaSections ;
  3058. nummodels = (int)csasections.GetSize() ;
  3059. for (n = 0 ; n < nummodels ; n++) {
  3060. pcsa = (CStringArray*) m_pciwParent->m_ciwnse.m_coaSectionArrays[n] ;
  3061. if ((numstrs = (int)pcsa->GetSize()) > 0) {
  3062. cs.Format("\t%s\r\n", csasections[n]) ;
  3063. cssummary += cs ;
  3064. bfoundone = true ;
  3065. for (n2 = 0 ; n2 < numstrs ; n2++) {
  3066. cs.Format("\t\t%s\r\n", pcsa->GetAt(n2)) ;
  3067. cssummary += cs ;
  3068. } ;
  3069. } ;
  3070. } ;
  3071. if (!bfoundone) {
  3072. cs.LoadString(IDS_NoneSumTxt) ;
  3073. cssummary += cs ;
  3074. } ;
  3075. // Add the nonstandard sections needed by models info to the summary
  3076. cs.LoadString(IDS_NonStdModelsSumTxt) ;
  3077. cssummary += cs ;
  3078. bfoundone = false ;
  3079. int numsections = (int) m_pciwParent->m_ciwnsms.m_csaSections.GetSize() ;
  3080. for (n = 0 ; n < numsections ; n++) {
  3081. pcsa = (CStringArray*)m_pciwParent->m_ciwnsms.m_coaModelsNeedingSecs[n];
  3082. if ((numstrs = (int)pcsa->GetSize()) > 0) {
  3083. cs.Format("\t%s\r\n", m_pciwParent->m_ciwnsms.m_csaSections[n]) ;
  3084. cssummary += cs ;
  3085. bfoundone = true ;
  3086. for (n2 = 0 ; n2 < numstrs ; n2++) {
  3087. cs.Format("\t\t%s\r\n", pcsa->GetAt(n2)) ;
  3088. cssummary += cs ;
  3089. } ;
  3090. } ;
  3091. } ;
  3092. if (!bfoundone) {
  3093. cs.LoadString(IDS_NoneSumTxt) ;
  3094. cssummary += cs ;
  3095. } ;
  3096. // Load the edit box, set the initialized flag, and return.
  3097. m_ceSummary.SetSel(0, -1) ;
  3098. m_ceSummary.ReplaceSel(cssummary) ;
  3099. m_ceSummary.SetSel(0, 0) ;
  3100. m_ceSummary.SetSel(-1, 0) ;
  3101. m_ceSummary.SetReadOnly() ;
  3102. m_bInitialized = true ; // Page is initialized now
  3103. return CPropertyPage::OnSetActive();
  3104. }
  3105. /////////////////////////////////////////////////////////////////////////////
  3106. // CNewINFSection dialog
  3107. CNewINFSection::CNewINFSection(CWnd* pParent /*=NULL*/)
  3108. : CDialog(CNewINFSection::IDD, pParent)
  3109. {
  3110. //{{AFX_DATA_INIT(CNewINFSection)
  3111. m_csNewSection = csEmpty;
  3112. //}}AFX_DATA_INIT
  3113. }
  3114. void CNewINFSection::DoDataExchange(CDataExchange* pDX)
  3115. {
  3116. CDialog::DoDataExchange(pDX);
  3117. //{{AFX_DATA_MAP(CNewINFSection)
  3118. DDX_Text(pDX, IDC_NewSectionBox, m_csNewSection);
  3119. //}}AFX_DATA_MAP
  3120. }
  3121. BEGIN_MESSAGE_MAP(CNewINFSection, CDialog)
  3122. //{{AFX_MSG_MAP(CNewINFSection)
  3123. //}}AFX_MSG_MAP
  3124. END_MESSAGE_MAP()
  3125. /////////////////////////////////////////////////////////////////////////////
  3126. // CNewINFSection message handlers
  3127. void CNewINFSection::OnOK()
  3128. {
  3129. UpdateData() ;
  3130. CDialog::OnOK();
  3131. }
  3132. /////////////////////////////////////////////////////////////////////////////
  3133. // CINFWizView
  3134. IMPLEMENT_DYNCREATE(CINFWizView, CEditView)
  3135. CINFWizView::CINFWizView()
  3136. {
  3137. m_pcicdCheckDoc = NULL ;
  3138. m_pcmcwCheckFrame = NULL ;
  3139. }
  3140. CINFWizView::~CINFWizView()
  3141. {
  3142. }
  3143. BEGIN_MESSAGE_MAP(CINFWizView, CEditView)
  3144. //{{AFX_MSG_MAP(CINFWizView)
  3145. ON_COMMAND(ID_FILE_Change_INF, OnFILEChangeINF)
  3146. ON_COMMAND(ID_FILE_Check_INF, OnFILECheckINF)
  3147. //}}AFX_MSG_MAP
  3148. END_MESSAGE_MAP()
  3149. /////////////////////////////////////////////////////////////////////////////
  3150. // CINFWizView drawing
  3151. void CINFWizView::OnDraw(CDC* pDC)
  3152. {
  3153. CDocument* pDoc = GetDocument();
  3154. // TODO: add draw code here
  3155. }
  3156. /////////////////////////////////////////////////////////////////////////////
  3157. // CINFWizView diagnostics
  3158. #ifdef _DEBUG
  3159. void CINFWizView::AssertValid() const
  3160. {
  3161. CEditView::AssertValid();
  3162. }
  3163. void CINFWizView::Dump(CDumpContext& dc) const
  3164. {
  3165. CEditView::Dump(dc);
  3166. }
  3167. #endif //_DEBUG
  3168. /////////////////////////////////////////////////////////////////////////////
  3169. // CINFWizView message handlers
  3170. void CINFWizView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
  3171. {
  3172. // TODO: Add your specialized code here and/or call the base class
  3173. CEditView::OnActivateView(bActivate, pActivateView, pDeactiveView);
  3174. }
  3175. void CINFWizView::OnInitialUpdate()
  3176. {
  3177. // Set the frame's window style and initialize the edit box.
  3178. GetParentFrame()->ModifyStyle(0, WS_OVERLAPPEDWINDOW) ;
  3179. CEditView::OnInitialUpdate();
  3180. // Set a default title for the window.
  3181. CString cs ;
  3182. cs.LoadString(IDS_INFFile) ;
  3183. GetDocument()->SetTitle(cs) ;
  3184. // Load the edit box with the contents of the INF file.
  3185. GetEditCtrl().SetSel(0, -1) ;
  3186. GetEditCtrl().ReplaceSel( ((CINFWizDoc*) GetDocument())->m_pciw->m_csINFContents ) ;
  3187. GetEditCtrl().SetSel(0, 0) ;
  3188. GetEditCtrl().SetSel(-1, 0) ;
  3189. // GetEditCtrl().SetReadOnly() ;
  3190. }
  3191. void CINFWizView::OnFILEChangeINF()
  3192. {
  3193. // Restart the wizard so that the users changes can be collected.
  3194. CINFWizDoc* pciwd = (CINFWizDoc*) GetDocument() ;
  3195. CINFWizard* pciw = pciwd->m_pciw ;
  3196. pciw->PrepareToRestart() ;
  3197. if (pciw->DoModal() == IDCANCEL)
  3198. return ;
  3199. // Regenerate the INF contents
  3200. if (!pciw->GenerateINFFile())
  3201. return ;
  3202. // Load the edit box with the contents of the new INF.
  3203. GetEditCtrl().SetSel(0, -1) ;
  3204. GetEditCtrl().ReplaceSel(pciw->m_csINFContents) ;
  3205. GetEditCtrl().SetSel(0, 0) ;
  3206. GetEditCtrl().SetSel(-1, 0) ;
  3207. GetEditCtrl().SetReadOnly() ;
  3208. }
  3209. void CINFWizView::OnFILECheckINF()
  3210. {
  3211. // This might take a while, so...
  3212. CWaitCursor cwc ;
  3213. // Remove the contents of any existing INF checking window and reset the
  3214. // checking flag.
  3215. ResetINFErrorWindow() ;
  3216. // Get a pointer to the wizard class because it contains some functions
  3217. // that will be useful to file checking process.
  3218. CINFWizDoc* pciwd = (CINFWizDoc*) GetDocument() ;
  3219. CINFWizard* pciw = pciwd->m_pciw ;
  3220. // Get a reference to the array of selected models and a count of them. Use
  3221. // them to loop through each model. Allocate all of the variables needed
  3222. // for processing including the string to hold the various paths that will
  3223. // be needed.
  3224. CStringArray& csamodels = pciw->GetINFModels() ;
  3225. int nummodels = (int)csamodels.GetSize() ;
  3226. CString csfspec, cspath, csmodel, cs, cstmp,csprojpath ;
  3227. //RAID 0001
  3228. if(pciw ->m_pcgc){
  3229. cstmp = pciwd->m_pcgc->GetPathName();
  3230. cstmp = cstmp.Left(cstmp.ReverseFind(csBSlash[0])); //cstmp are used instead GetW2000()
  3231. csprojpath = cstmp.Left(cstmp.ReverseFind(csBSlash[0])+1) ;
  3232. } //END RAID 0001
  3233. else {
  3234. csprojpath = pciwd->m_pcpr->GetProjFSpec() ;
  3235. csprojpath = csprojpath.Left(csprojpath.ReverseFind(csBSlash[0]) + 1) ;
  3236. }
  3237. CFileStatus cfs ;
  3238. int n ;
  3239. BOOL bexists ;
  3240. // Do all of the checking for each model before moving on to the next one.
  3241. for (n = 0 ; n < nummodels ; n++) {
  3242. csmodel = csamodels[n] ;
  3243. // Make sure that the GPD file for the model exists.
  3244. csfspec = pciw->GetModelFile(csmodel, true) ;
  3245. if (!(bexists = CFile::GetStatus(csfspec, cfs))) {
  3246. cs.Format(IDS_INFChk_NoModErr, csmodel, csfspec) ;
  3247. PostINFCheckingMessage(cs) ;
  3248. } ;
  3249. cspath = csfspec.Left(csfspec.ReverseFind(csBSlash[0]) + 1) ;
  3250. // Verify the existence of the files referenced in include statements
  3251. // in the current GPD file iff the GPD file exists.
  3252. if (bexists)
  3253. CheckIncludeFiles(csfspec, cspath, csmodel) ;
  3254. // Check for the existence of the ICM files (if any) for this GPD.
  3255. CheckArrayOfFiles((CStringArray*) pciw->m_ciwip.m_coaProfileArrays[n],
  3256. csfspec, cspath, csprojpath, csmodel,
  3257. IDS_INFChk_NoICMFileErr) ;
  3258. // Check for the existence of the nonstd files (if any) for this GPD.
  3259. CheckArrayOfFiles((CStringArray*) pciw->m_ciwef.m_coaExtraFSArrays[n],
  3260. csfspec, cspath, csprojpath, csmodel,
  3261. IDS_INFChk_NoNonStdFileErr) ;
  3262. } ;
  3263. // Check for the existence of the resource DLL. First look for it in the
  3264. // project directory. If it isn't there, try the W2K directory.
  3265. // RAID 0001
  3266. if(pciw->m_pcgc)
  3267. cs = pciw->m_pcgc->ModelData()->GetKeywordValue(pciw->m_pcgc->GetPathName(),_T("ResourceDLL"));
  3268. else{ //END RAID 0001
  3269. cs = pciwd->m_pcpr->DriverName() ;
  3270. cs = cs.Left(8) + _T(".dll") ; // Resource DLL name.
  3271. }
  3272. if (!CFile::GetStatus(csprojpath + cs, cfs)) {
  3273. cstmp = (pciw->m_pcgc) ? cstmp + csBSlash : pciwd->m_pcpr->GetW2000Path() + csBSlash ; //RAID 0001
  3274. if (!CFile::GetStatus(cstmp + cs, cfs)) {
  3275. cstmp.Format(IDS_INFChk_NoResDLLErr, (pciw->m_pcgc)? cs :
  3276. pciwd->m_pcpr->DriverName(), cs) ; //RAID 0001
  3277. PostINFCheckingMessage(cstmp) ;
  3278. } ;
  3279. } ;
  3280. // Tell the user if no problems were found.
  3281. if (!m_bChkingErrsFound)
  3282. AfxMessageBox(IDS_INFChecksOK, MB_ICONINFORMATION) ;
  3283. }
  3284. void CINFWizView::CheckArrayOfFiles(CStringArray* pcsa, CString& csfspec,
  3285. CString& cspath, CString& csprojpath,
  3286. CString& csmodel, int nerrid)
  3287. {
  3288. // There is nothing to do if there are no filespecs in the array.
  3289. int numfiles ;
  3290. if ((numfiles = (int)pcsa->GetSize()) == 0)
  3291. return ;
  3292. // Variables needed for file existence checking
  3293. int n ;
  3294. BOOL bexists ;
  3295. CString csfile, csmsg ;
  3296. CFileStatus cfs ;
  3297. // Check for the existence of each file.
  3298. for (n = 0 ; n < numfiles ; n++) {
  3299. csfile = pcsa->GetAt(n) ;
  3300. // If the file string contains a full filespec, just check it.
  3301. if (csfile[1] == _T(':'))
  3302. bexists = CFile::GetStatus(csfile, cfs) ;
  3303. // Otherwise, add the GPD path and, if needed, the project path to the
  3304. // file string and check to see if the file is there.
  3305. else {
  3306. if (!(bexists = CFile::GetStatus(cspath + csfile, cfs)))
  3307. bexists = CFile::GetStatus(csprojpath + csfile, cfs) ;
  3308. } ;
  3309. // Post a message if the file was not found.
  3310. if (!bexists) {
  3311. csmsg.Format(nerrid, csmodel, csfile) ;
  3312. PostINFCheckingMessage(csmsg) ;
  3313. } ;
  3314. } ;
  3315. }
  3316. void CINFWizView::CheckIncludeFiles(CString& csfspec, CString& cspath,
  3317. CString& csmodel)
  3318. {
  3319. // Variables needed to read the GPD and check include files.
  3320. CStringArray csagpdfile ;
  3321. CString csinc(_T("*Include:")), cs, cstmp ;
  3322. int n, numstrs, nloc ;
  3323. CFileStatus cfs ;
  3324. // Include files can only be checked if the GPD file can be read.
  3325. if (LoadFile(csfspec, csagpdfile)) {
  3326. numstrs = (int)csagpdfile.GetSize() ;
  3327. // Check each line in the GPD file to see if it contains an include
  3328. // statement.
  3329. for (n = 0 ; n < numstrs ; n++) {
  3330. // Skip statement if not include statement
  3331. if ((nloc = csagpdfile[n].Find(csinc)) == -1)
  3332. continue ;
  3333. // Isolate the filespec in the include statement
  3334. cs = csagpdfile[n].Mid(nloc + csinc.GetLength()) ;
  3335. cs.TrimLeft() ;
  3336. cs.TrimRight() ;
  3337. if (cs[0] == csQuote[0]) // Remove quotes
  3338. cs = cs.Mid(1, cs.GetLength() - 2) ;
  3339. // If the include file's filespec is relative, add the GPD's
  3340. // path to it. Then test for the file's existence. Post a
  3341. // message if the file does not exist.
  3342. if (cs[1] != _T(':'))
  3343. cs = cspath + cs ;
  3344. if (!CFile::GetStatus(cs, cfs)) {
  3345. cstmp.Format(IDS_INFChk_NoIncFileErr, csmodel, cs,
  3346. csfspec) ;
  3347. PostINFCheckingMessage(cstmp) ;
  3348. } ;
  3349. } ;
  3350. // Complain if the GPD file could not be read.
  3351. } else {
  3352. cstmp.Format(IDS_INFChk_GPDReadErr, csfspec) ;
  3353. AfxMessageBox(cstmp, MB_ICONEXCLAMATION) ;
  3354. } ;
  3355. }
  3356. /******************************************************************************
  3357. CINFWizView::PostINFCheckingMessage
  3358. Create the checking results window if needed and then post a message to it.
  3359. ******************************************************************************/
  3360. bool CINFWizView::PostINFCheckingMessage(CString& csmsg)
  3361. {
  3362. // Clean up before continuing if the user closed the checking window.
  3363. if (m_pcicdCheckDoc && m_pcmcwCheckFrame
  3364. && !IsWindow(m_pcmcwCheckFrame->m_hWnd)) {
  3365. m_pcicdCheckDoc = NULL ;
  3366. m_pcmcwCheckFrame = NULL ;
  3367. } ;
  3368. // Create the INF checking, error display window if one does not exist.
  3369. if (m_pcicdCheckDoc == NULL) {
  3370. m_pcicdCheckDoc = new CINFCheckDoc ;
  3371. if (m_pcicdCheckDoc == NULL)
  3372. return false ;
  3373. CString cstitle ; // Set the new window's title
  3374. cstitle.Format(IDS_INFCheckTitle, GetDocument()->GetTitle()) ;
  3375. m_pcicdCheckDoc->SetTitle(cstitle) ;
  3376. CMultiDocTemplate* pcmdt = WSCheckTemplate() ;
  3377. m_pcmcwCheckFrame = (CMDIChildWnd *) pcmdt->CreateNewFrame(m_pcicdCheckDoc, NULL) ;
  3378. if (m_pcmcwCheckFrame) {
  3379. pcmdt->InitialUpdateFrame(m_pcmcwCheckFrame, m_pcicdCheckDoc, TRUE) ;
  3380. pcmdt->AddDocument(m_pcicdCheckDoc) ;
  3381. } else {
  3382. delete m_pcicdCheckDoc ;
  3383. m_pcicdCheckDoc = NULL ;
  3384. return false ;
  3385. } ;
  3386. } ;
  3387. // Post the message and return
  3388. m_pcicdCheckDoc->PostINFChkMsg(csmsg) ;
  3389. m_bChkingErrsFound = true ;
  3390. return true ;
  3391. }
  3392. /******************************************************************************
  3393. CINFWizView::ResetINFErrorWindow
  3394. If there is an existing checking results window for this INF file, clear
  3395. out its contents. Next, initialize a flag that has to be set before the
  3396. checking begins.
  3397. ******************************************************************************/
  3398. void CINFWizView::ResetINFErrorWindow()
  3399. {
  3400. // Clear the checking window if there is one.
  3401. if (m_pcicdCheckDoc && m_pcmcwCheckFrame && IsWindow(m_pcmcwCheckFrame->m_hWnd))
  3402. m_pcicdCheckDoc->DeleteAllMessages() ;
  3403. else {
  3404. m_pcicdCheckDoc = NULL ;
  3405. m_pcmcwCheckFrame = NULL ;
  3406. // DEAD_BUG - Do I need to delete these classes first??? // No you can't.
  3407. } ;
  3408. // Initialize checking flag
  3409. m_bChkingErrsFound = false ;
  3410. }
  3411. /////////////////////////////////////////////////////////////////////////////
  3412. // CINFWizDoc
  3413. IMPLEMENT_DYNCREATE(CINFWizDoc, CDocument)
  3414. CINFWizDoc::CINFWizDoc()
  3415. {
  3416. // This constructor is called when the File Open command is used. That is
  3417. // not supported at this point.
  3418. m_bGoodInit = false ;
  3419. }
  3420. CINFWizDoc::CINFWizDoc(CProjectRecord* pcpr, CINFWizard* pciw)
  3421. {
  3422. // Save the input parameters.
  3423. m_pcpr = pcpr ;
  3424. m_pciw = pciw ;
  3425. ASSERT(m_pciw != NULL) ;
  3426. // Class is correctly constructed.
  3427. m_bGoodInit = true ;
  3428. }
  3429. //RAID 0001
  3430. CINFWizDoc::CINFWizDoc(CGPDContainer * pcgc, CINFWizard * pciw)
  3431. {
  3432. m_pcgc = pcgc ;
  3433. m_pciw = pciw ;
  3434. ASSERT(m_pciw != NULL) ;
  3435. // Class is correctly constructed.
  3436. m_bGoodInit = true ;
  3437. }
  3438. // RAID 0001
  3439. BOOL CINFWizDoc::OnNewDocument()
  3440. {
  3441. // Creating a new INF doc in this way is not supported.
  3442. return FALSE ;
  3443. //if (!CDocument::OnNewDocument())
  3444. // return FALSE;
  3445. //return TRUE;
  3446. }
  3447. CINFWizDoc::~CINFWizDoc()
  3448. {
  3449. // Do nothing if this class was not correctly constructed.
  3450. if (!m_bGoodInit)
  3451. return ;
  3452. // Free the wizard classes if they exist.
  3453. if (m_pciw != NULL)
  3454. delete m_pciw ;
  3455. }
  3456. BEGIN_MESSAGE_MAP(CINFWizDoc, CDocument)
  3457. //{{AFX_MSG_MAP(CINFWizDoc)
  3458. // NOTE - the ClassWizard will add and remove mapping macros here.
  3459. //}}AFX_MSG_MAP
  3460. END_MESSAGE_MAP()
  3461. /////////////////////////////////////////////////////////////////////////////
  3462. // CINFWizDoc diagnostics
  3463. #ifdef _DEBUG
  3464. void CINFWizDoc::AssertValid() const
  3465. {
  3466. CDocument::AssertValid();
  3467. }
  3468. void CINFWizDoc::Dump(CDumpContext& dc) const
  3469. {
  3470. CDocument::Dump(dc);
  3471. }
  3472. #endif //_DEBUG
  3473. /////////////////////////////////////////////////////////////////////////////
  3474. // CINFWizDoc serialization
  3475. void CINFWizDoc::Serialize(CArchive& ar)
  3476. {
  3477. unsigned unumbytes ;
  3478. CString& csinfcontents = m_pciw->m_csINFContents ;
  3479. if (ar.IsStoring())
  3480. {
  3481. unumbytes = csinfcontents.GetLength() ;
  3482. ar.Write(csinfcontents.GetBuffer(unumbytes + 10), unumbytes) ;
  3483. csinfcontents.ReleaseBuffer() ;
  3484. }
  3485. else
  3486. {
  3487. // TODO: add loading code here
  3488. }
  3489. }
  3490. /////////////////////////////////////////////////////////////////////////////
  3491. // CINFWizDoc commands
  3492. void CINFWizDoc::OnCloseDocument()
  3493. {
  3494. // Clean up the wizard if the class was correctly constructed.
  3495. if (m_bGoodInit) {
  3496. delete m_pciw ;
  3497. m_pciw = NULL ;
  3498. } ;
  3499. CDocument::OnCloseDocument();
  3500. }
  3501. BOOL CINFWizDoc::OnOpenDocument(LPCTSTR lpszPathName)
  3502. {
  3503. // Opening an INF doc in this way is not supported so complain and exit.
  3504. CString csmsg ;
  3505. csmsg.LoadString(IDS_INFOpenError) ;
  3506. AfxMessageBox(csmsg, MB_ICONINFORMATION) ;
  3507. return FALSE ;
  3508. //if (!CDocument::OnOpenDocument(lpszPathName))
  3509. // return FALSE;
  3510. // TODO: Add your specialized creation code here
  3511. //return TRUE;
  3512. }
  3513. /////////////////////////////////////////////////////////////////////////////
  3514. // CINFCheckView
  3515. IMPLEMENT_DYNCREATE(CINFCheckView, CFormView)
  3516. CINFCheckView::CINFCheckView()
  3517. : CFormView(CINFCheckView::IDD)
  3518. {
  3519. //{{AFX_DATA_INIT(CINFCheckView)
  3520. // NOTE: the ClassWizard will add member initialization here
  3521. //}}AFX_DATA_INIT
  3522. }
  3523. CINFCheckView::~CINFCheckView()
  3524. {
  3525. }
  3526. void CINFCheckView::DoDataExchange(CDataExchange* pDX)
  3527. {
  3528. CFormView::DoDataExchange(pDX);
  3529. //{{AFX_DATA_MAP(CINFCheckView)
  3530. DDX_Control(pDX, IDC_ErrWrnLstBox, m_clbMissingFiles);
  3531. //}}AFX_DATA_MAP
  3532. }
  3533. BEGIN_MESSAGE_MAP(CINFCheckView, CFormView)
  3534. //{{AFX_MSG_MAP(CINFCheckView)
  3535. // NOTE - the ClassWizard will add and remove mapping macros here.
  3536. //}}AFX_MSG_MAP
  3537. END_MESSAGE_MAP()
  3538. /////////////////////////////////////////////////////////////////////////////
  3539. // CINFCheckView diagnostics
  3540. #ifdef _DEBUG
  3541. void CINFCheckView::AssertValid() const
  3542. {
  3543. CFormView::AssertValid();
  3544. }
  3545. void CINFCheckView::Dump(CDumpContext& dc) const
  3546. {
  3547. CFormView::Dump(dc);
  3548. }
  3549. #endif //_DEBUG
  3550. /////////////////////////////////////////////////////////////////////////////
  3551. // CINFCheckView message handlers
  3552. /******************************************************************************
  3553. CINFCheckView::OnInitialUpdate
  3554. Resize the frame to better fit the visible controls in it.
  3555. ******************************************************************************/
  3556. void CINFCheckView::OnInitialUpdate()
  3557. {
  3558. CRect crtxt ; // Coordinates of list box label
  3559. CRect crlbfrm ; // Coordinates of list box and frame
  3560. CFormView::OnInitialUpdate() ;
  3561. // Get the dimensions of the list box label
  3562. HWND hlblhandle ;
  3563. GetDlgItem(IDC_INFCLabel, &hlblhandle) ;
  3564. ::GetWindowRect(hlblhandle, crtxt) ;
  3565. crtxt.NormalizeRect() ;
  3566. // Get the dimensions of the list box and then add the height of the label
  3567. // to those dimensions.
  3568. m_clbMissingFiles.GetWindowRect(crlbfrm) ;
  3569. crlbfrm.bottom += crtxt.Height() ;
  3570. // Make sure the frame is big enough for these 2 controls plus a little bit
  3571. // more.
  3572. crlbfrm.right += 40 ;
  3573. crlbfrm.bottom += 40 ;
  3574. GetParentFrame()->CalcWindowRect(crlbfrm) ;
  3575. GetParentFrame()->SetWindowPos(NULL, 0, 0, crlbfrm.Width(), crlbfrm.Height(),
  3576. SWP_NOZORDER | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOACTIVATE) ;
  3577. }
  3578. /******************************************************************************
  3579. CINFCheckView::PostINFChkMsg
  3580. Add an error or warning message to the list box.
  3581. ******************************************************************************/
  3582. void CINFCheckView::PostINFChkMsg(CString& csmsg)
  3583. {
  3584. int n = m_clbMissingFiles.AddString(csmsg) ;
  3585. }
  3586. /******************************************************************************
  3587. CINFCheckView::DeleteAllMessages
  3588. Delete all of the messages in the list box.
  3589. ******************************************************************************/
  3590. void CINFCheckView::DeleteAllMessages(void)
  3591. {
  3592. m_clbMissingFiles.ResetContent() ;
  3593. }
  3594. /////////////////////////////////////////////////////////////////////////////
  3595. // CINFCheckDoc
  3596. IMPLEMENT_DYNCREATE(CINFCheckDoc, CDocument)
  3597. CINFCheckDoc::CINFCheckDoc()
  3598. {
  3599. }
  3600. BOOL CINFCheckDoc::OnNewDocument()
  3601. {
  3602. if (!CDocument::OnNewDocument())
  3603. return FALSE;
  3604. return TRUE;
  3605. }
  3606. CINFCheckDoc::~CINFCheckDoc()
  3607. {
  3608. }
  3609. /******************************************************************************
  3610. CINFCheckDoc::PostINFChkMsg
  3611. Pass the specified request on to what should be the one and only view
  3612. attached to this document.
  3613. ******************************************************************************/
  3614. void CINFCheckDoc::PostINFChkMsg(CString& csmsg)
  3615. {
  3616. POSITION pos = GetFirstViewPosition() ;
  3617. if (pos != NULL) {
  3618. CINFCheckView* pcicv = (CINFCheckView *) GetNextView(pos) ;
  3619. pcicv->PostINFChkMsg(csmsg) ;
  3620. pcicv->UpdateWindow() ;
  3621. } ;
  3622. }
  3623. /******************************************************************************
  3624. CINFCheckDoc::DeleteAllMessages
  3625. Pass the specified request on to what should be the one and only view
  3626. attached to this document.
  3627. ******************************************************************************/
  3628. void CINFCheckDoc::DeleteAllMessages(void)
  3629. {
  3630. POSITION pos = GetFirstViewPosition() ;
  3631. if (pos != NULL) {
  3632. CINFCheckView* pcicv = (CINFCheckView *) GetNextView(pos) ;
  3633. pcicv->DeleteAllMessages() ;
  3634. pcicv->UpdateWindow() ;
  3635. } ;
  3636. }
  3637. BEGIN_MESSAGE_MAP(CINFCheckDoc, CDocument)
  3638. //{{AFX_MSG_MAP(CINFCheckDoc)
  3639. // NOTE - the ClassWizard will add and remove mapping macros here.
  3640. //}}AFX_MSG_MAP
  3641. END_MESSAGE_MAP()
  3642. /////////////////////////////////////////////////////////////////////////////
  3643. // CINFCheckDoc diagnostics
  3644. #ifdef _DEBUG
  3645. void CINFCheckDoc::AssertValid() const
  3646. {
  3647. CDocument::AssertValid();
  3648. }
  3649. void CINFCheckDoc::Dump(CDumpContext& dc) const
  3650. {
  3651. CDocument::Dump(dc);
  3652. }
  3653. #endif //_DEBUG
  3654. /////////////////////////////////////////////////////////////////////////////
  3655. // CINFCheckDoc serialization
  3656. void CINFCheckDoc::Serialize(CArchive& ar)
  3657. {
  3658. if (ar.IsStoring())
  3659. {
  3660. // TODO: add storing code here
  3661. }
  3662. else
  3663. {
  3664. // TODO: add loading code here
  3665. }
  3666. }
  3667. //////////////////////////////////////////////////////////////////////
  3668. // Construction/Destruction
  3669. //////////////////////////////////////////////////////////////////////
  3670. CCompatID::CCompatID( CString csMfg, CString csModel )
  3671. {
  3672. // Save the Parameters
  3673. m_csMfg = csMfg;
  3674. m_csModel = csModel;
  3675. }
  3676. CCompatID::~CCompatID()
  3677. {
  3678. }
  3679. void CCompatID::TransString(CString &csInput)
  3680. {
  3681. // Walk Through the String changing Spaces to Underscores
  3682. DWORD i;
  3683. TCHAR cszSpace[] = TEXT(" ");
  3684. TCHAR cszUS[] = TEXT("_");
  3685. DWORD dwLength = csInput.GetLength();
  3686. for ( i = 0; i < dwLength; i++ )
  3687. {
  3688. if (csInput.GetAt(i) == cszSpace[0])
  3689. csInput.SetAt(i, cszUS[0]);
  3690. }
  3691. }
  3692. USHORT CCompatID::GetCheckSum(CString csValue)
  3693. {
  3694. WORD wCRC16a[16]={
  3695. 0000000, 0140301, 0140601, 0000500,
  3696. 0141401, 0001700, 0001200, 0141101,
  3697. 0143001, 0003300, 0003600, 0143501,
  3698. 0002400, 0142701, 0142201, 0002100,
  3699. };
  3700. WORD wCRC16b[16]={
  3701. 0000000, 0146001, 0154001, 0012000,
  3702. 0170001, 0036000, 0024000, 0162001,
  3703. 0120001, 0066000, 0074000, 0132001,
  3704. 0050000, 0116001, 0104001, 0043000,
  3705. };
  3706. BYTE byte;
  3707. USHORT CS=0;
  3708. DWORD dwSize = csValue.GetLength();
  3709. PBYTE ptr = (PBYTE) csValue.GetBuffer(dwSize);
  3710. dwSize *= sizeof(TCHAR);
  3711. for ( ; dwSize ; --dwSize, ++ptr) {
  3712. byte = (BYTE)(((WORD)*ptr)^((WORD)CS)); // Xor CRC with new char
  3713. CS = ((CS)>>8) ^ wCRC16a[byte&0x0F] ^ wCRC16b[byte>>4];
  3714. }
  3715. csValue.ReleaseBuffer();
  3716. return CS;
  3717. }
  3718. void CCompatID::GenerateID(CString &csCompID)
  3719. {
  3720. CString csTransModel, csMfgModel;
  3721. // Build the Mfg Model string
  3722. csMfgModel = m_csMfg;
  3723. csMfgModel += m_csModel;
  3724. // Convert the spaces to underscores
  3725. TransString( csMfgModel );
  3726. csTransModel = m_csModel;
  3727. TransString( csTransModel );
  3728. csCompID = csMfgModel;
  3729. // Get the CheckSum
  3730. USHORT usCheckSum = GetCheckSum( csCompID );
  3731. // Now chop off the Mfg/Model string if too Long.
  3732. if ( csCompID.GetLength() > MAX_DEVNODE_NAME_ROOT )
  3733. {
  3734. csCompID.GetBufferSetLength(MAX_DEVNODE_NAME_ROOT);
  3735. csCompID.ReleaseBuffer();
  3736. }
  3737. TCHAR szCheckSum[6] = { 0x00 };
  3738. // _itot( usCheckSum, szCheckSum, 16 );
  3739. StringCchPrintf( szCheckSum, CCHOF(szCheckSum), _T("%04X"), usCheckSum );
  3740. csCompID +=szCheckSum;
  3741. //csCompID += TEXT(",");
  3742. //csCompID += csTransModel;
  3743. }