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.

1584 lines
47 KiB

  1. /******************************************************************************
  2. Source File: New Project Wizard.CPP
  3. This contains the implementation of the classes that make u the new project
  4. wizard- a key component of this tool.
  5. Copyright (c) 1997 by Microsoft Corporation. All Rights Reserved.
  6. A Pretty Penny Enterprises Production
  7. Change History:
  8. 02-03-1997 Bob_Kjelgaard@Prodigy.Net Created it
  9. 02-28-1998 Ekevans@acsgroup.com The UI for the wizard was changed
  10. to only support conversion to Win2K minidrivers. Be this as
  11. it may, most - if not all - of the support in this file for
  12. other conversions is still in this file but is unused.
  13. ******************************************************************************/
  14. #include "StdAfx.h"
  15. #include <gpdparse.h>
  16. #include "MiniDev.H"
  17. #include "Resource.H"
  18. #include "comctrls.h"
  19. #include "NewProj.H"
  20. #include <CodePage.H>
  21. #include <dlgs.h>
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CNewConvertWizard
  29. // We use "this" to allow the pages to hook back to us- disable the
  30. // warnings this causes, as none will use the pointer until after
  31. // we have been initialized.
  32. #pragma warning(disable : 4355)
  33. CNewConvertWizard::CNewConvertWizard(CProjectRecord& cprFor, CWnd* pParentWnd) :
  34. CPropertySheet(NewProjectWizardTitle, pParentWnd), m_cfnwp(*this),
  35. m_cprThis(cprFor), m_cst(*this), m_csd(*this), m_crut(*this),
  36. m_crng(*this), m_ccf(*this), m_cmcp(*this), m_cgpds(*this), m_cdcps(*this) {
  37. m_bFastConvert = TRUE;
  38. m_eGPDConvert = CommonRCWithSpoolerNames;
  39. AddPage(&m_cfnwp); //CFirstNewWizardPage
  40. AddPage(&m_cst); //CSelectTargets
  41. AddPage(&m_csd); //CSelectDestinations
  42. AddPage(&m_cdcps); //CDefaultCodePageSel
  43. AddPage(&m_cgpds); //CGPDSelection
  44. AddPage(&m_crut); //CRunUniTool
  45. AddPage(&m_cmcp); //CMapCodePages
  46. AddPage(&m_ccf); //CConvertFiles
  47. AddPage(&m_crng); //CRunNTGPC
  48. SetWizardMode();
  49. }
  50. #pragma warning(default : 4355)
  51. CNewConvertWizard::~CNewConvertWizard() {
  52. }
  53. BEGIN_MESSAGE_MAP(CNewConvertWizard, CPropertySheet)
  54. //{{AFX_MSG_MAP(CNewConvertWizard)
  55. ON_WM_NCCREATE()
  56. //}}AFX_MSG_MAP
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CNewConvertWizard message handlers
  60. // restore the system menu to the wizard, and allow it to be minimized
  61. BOOL CNewConvertWizard::OnNcCreate(LPCREATESTRUCT lpCreateStruct) {
  62. ModifyStyle(WS_CHILD, WS_MINIMIZEBOX | WS_SYSMENU);
  63. if (!CPropertySheet::OnNcCreate(lpCreateStruct))
  64. return FALSE;
  65. return TRUE;
  66. }
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CFirstNewWizardPage property page
  69. CFirstNewWizardPage::CFirstNewWizardPage(CNewConvertWizard& cnpwOwner) :
  70. CPropertyPage(CFirstNewWizardPage::IDD), m_cnpwOwner(cnpwOwner) {
  71. //{{AFX_DATA_INIT(CFirstNewWizardPage)
  72. // NOTE: the ClassWizard will add member initialization here
  73. //}}AFX_DATA_INIT
  74. }
  75. CFirstNewWizardPage::~CFirstNewWizardPage() {
  76. }
  77. void CFirstNewWizardPage::DoDataExchange(CDataExchange* pDX) {
  78. CPropertyPage::DoDataExchange(pDX);
  79. //{{AFX_DATA_MAP(CFirstNewWizardPage)
  80. // NOTE: the ClassWizard will add DDX and DDV calls here
  81. //}}AFX_DATA_MAP
  82. }
  83. BEGIN_MESSAGE_MAP(CFirstNewWizardPage, CPropertyPage)
  84. //{{AFX_MSG_MAP(CFirstNewWizardPage)
  85. //}}AFX_MSG_MAP
  86. END_MESSAGE_MAP()
  87. /////////////////////////////////////////////////////////////////////////////
  88. // CFirstNewWizardPage message handlers
  89. BOOL CFirstNewWizardPage::OnSetActive() {
  90. // We wish to disable the "Back" button here.
  91. m_cnpwOwner.SetWizardButtons(PSWIZB_NEXT);
  92. m_cnpwOwner.GetDlgItem(IDHELP)->ShowWindow(SW_HIDE) ;
  93. return CPropertyPage::OnSetActive();
  94. }
  95. /******************************************************************************
  96. CFirstNewWizardPage::OnWizardNext
  97. When Next is pressed, we invoke a file open dialog to allow us to collect the
  98. source RC file information.
  99. ******************************************************************************/
  100. LRESULT CFirstNewWizardPage::OnWizardNext()
  101. {
  102. CString cswrcfspec ; // Filespec for RC/RC3/W31 file
  103. // When the "Next" button is pushed, we need to find the driver we are
  104. // going to work with. Keep prompting the user until a valid filespec
  105. // is returned.
  106. do {
  107. CFileDialog cfd(TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
  108. "Driver Resource Scripts (*.w31,*.rc)|*.w31;*.rc||",
  109. &m_cnpwOwner);
  110. CString csTitle;
  111. csTitle.LoadString(OpenRCDialogTitle);
  112. cfd.m_ofn.lpstrTitle = csTitle;
  113. if (cfd.DoModal() != IDOK)
  114. return -1;
  115. // Save the filespec and then exit the loop if the file is ok.
  116. // Otherwise, reprompt.
  117. cswrcfspec = cfd.GetPathName() ;
  118. } while (IsWrongNT4File(cswrcfspec)) ;
  119. // Collect the RC file name
  120. m_cnpwOwner.Project().SetSourceRCFile(cswrcfspec) ;
  121. // The only conversion supported now is the so called "Fast Conversion" so
  122. // set that flag and skip some of the other wizard pages and go straight to
  123. // the destinations page.
  124. m_cnpwOwner.FastConvert(TRUE) ;
  125. return CSelectDestinations::IDD ;
  126. }
  127. /******************************************************************************
  128. CFirstNewWizardPage::IsWrongNT4File
  129. NT 4.0 minidrivers are made up of (among other things) both an RC file and a
  130. W31 file. NT 4.0 minidriver conversions must be driven from the W31 file.
  131. So, if the filespec references an RC file, check the file to see if it is an
  132. NT 4 file. If it is, look for a W31 file and ask the user if it should be
  133. used. If yes, change the filespec and return false. If no or there is no
  134. W31 file, return true so that the user will be reprompted.
  135. ******************************************************************************/
  136. bool CFirstNewWizardPage::IsWrongNT4File(CString& cswrcfspec)
  137. {
  138. CString cstmp1 ; // Temp string
  139. CString cstmp2 ; // Temp string
  140. CString cstmp3 ; // Temp string
  141. // If the file does not end with .RC, return false (ok).
  142. cstmp1.LoadString(IDS_RCExt) ;
  143. int nlen = cstmp1.GetLength() ;
  144. cstmp2 = cswrcfspec.Right(nlen) ;
  145. if (cstmp1.CompareNoCase(cstmp2) != 0)
  146. return false ;
  147. // The filespec references an RC file so it must be read and scanned to
  148. // see if this is an NT 4.0 RC file. Start by reading the file...
  149. CStringArray csacontents ;
  150. if (!LoadFile(cswrcfspec, csacontents))
  151. return FALSE ;
  152. // Now scan the file looking for a "2 RC_TABLES ... nt.gpc" line that will
  153. // indicate that this is an NT 4.0 file.
  154. cstmp1.LoadString(IDS_RCTables) ;
  155. cstmp2.LoadString(IDS_RCTabID) ;
  156. cstmp3.LoadString(IDS_RCTabFile) ;
  157. int n ;
  158. for (n = 0 ; n < csacontents.GetSize() ; n++) {
  159. // Skip this line if "RC_TABLES" is not in the line.
  160. if (csacontents[n].Find(cstmp1) < 0)
  161. continue ;
  162. // Skip this line if it doesn't start with "2"
  163. csacontents[n].TrimLeft() ;
  164. if (csacontents[n].Find(cstmp2) != 0)
  165. continue ;
  166. // If this line contains "nt.gpc", this is the one we want so exit the
  167. // loop.
  168. csacontents[n].MakeLower() ;
  169. if (csacontents[n].Find(cstmp3) >= 0)
  170. break ;
  171. } ;
  172. // If this is NOT an NT 4.0 RC file, return false (ok).
  173. if (n >= csacontents.GetSize())
  174. return false ;
  175. // We have an NT 4.0 RC file, check to see if there is a W31 file in the
  176. // same dir. If there is, ask the user if he wants to use it and do so
  177. // if he says yes.
  178. cstmp1 = cswrcfspec.Left(cswrcfspec.GetLength() - nlen) ;
  179. cstmp2.LoadString(IDS_W31Ext) ;
  180. cstmp1 += cstmp2 ;
  181. CFileFind cff ;
  182. if (cff.FindFile(cstmp1)) {
  183. cstmp3.Format(IDS_SwitchToW31, cswrcfspec, cstmp1) ;
  184. if (AfxMessageBox(cstmp3, MB_YESNO) == IDYES) {
  185. cswrcfspec = cstmp1 ;
  186. return false ;
  187. } ;
  188. } ;
  189. // Either there is no W31 file or the user chose not to use it so return
  190. // true to indicate that the user should be reprompted to select another
  191. // file.
  192. cstmp1.Format(IDS_BadNT4File, cswrcfspec) ;
  193. AfxMessageBox(cstmp1) ;
  194. return true ;
  195. }
  196. /////////////////////////////////////////////////////////////////////////////
  197. // CSelectTargets property page
  198. CSelectTargets::CSelectTargets(CNewConvertWizard& cnpwOwner) :
  199. CPropertyPage(CSelectTargets::IDD), m_cnpwOwner(cnpwOwner) {
  200. //{{AFX_DATA_INIT(CSelectTargets)
  201. // NOTE: the ClassWizard will add member initialization here
  202. //}}AFX_DATA_INIT
  203. }
  204. CSelectTargets::~CSelectTargets() {
  205. }
  206. void CSelectTargets::DoDataExchange(CDataExchange* pDX) {
  207. CPropertyPage::DoDataExchange(pDX);
  208. //{{AFX_DATA_MAP(CSelectTargets)
  209. // NOTE: the ClassWizard will add DDX and DDV calls here
  210. //}}AFX_DATA_MAP
  211. }
  212. BEGIN_MESSAGE_MAP(CSelectTargets, CPropertyPage)
  213. //{{AFX_MSG_MAP(CSelectTargets)
  214. //}}AFX_MSG_MAP
  215. END_MESSAGE_MAP()
  216. /////////////////////////////////////////////////////////////////////////////
  217. // CSelectTargets message handlers
  218. BOOL CSelectTargets::OnSetActive() {
  219. // We need to enable the "Back" button...
  220. m_cnpwOwner.SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  221. SetDlgItemText(IDC_DriverName, m_cnpwOwner.Project().DriverName());
  222. return CPropertyPage::OnSetActive();
  223. }
  224. // Initialize the controls
  225. BOOL CSelectTargets::OnInitDialog() {
  226. CPropertyPage::OnInitDialog();
  227. CheckDlgButton(IDC_TargetNT40,
  228. m_cnpwOwner.Project().IsTargetEnabled(WinNT40));
  229. CheckDlgButton(IDC_TargetNT3x,
  230. m_cnpwOwner.Project().IsTargetEnabled(WinNT3x));
  231. CheckDlgButton(IDC_TargetWin95,
  232. m_cnpwOwner.Project().IsTargetEnabled(Win95));
  233. return TRUE; // return TRUE unless you set the focus to a control
  234. // EXCEPTION: OCX Property Pages should return FALSE
  235. }
  236. LRESULT CSelectTargets::OnWizardNext() {
  237. // Set the flags according to the controls...
  238. m_cnpwOwner.Project().EnableTarget(WinNT40,
  239. IsDlgButtonChecked(IDC_TargetNT40));
  240. m_cnpwOwner.Project().EnableTarget(WinNT3x,
  241. IsDlgButtonChecked(IDC_TargetNT3x));
  242. m_cnpwOwner.Project().EnableTarget(Win95,
  243. IsDlgButtonChecked(IDC_TargetWin95));
  244. CString csName;
  245. GetDlgItemText(IDC_DriverName, csName);
  246. m_cnpwOwner.Project().Rename(csName);
  247. return CPropertyPage::OnWizardNext();
  248. }
  249. /////////////////////////////////////////////////////////////////////////////
  250. // CSelectDestinations property page
  251. /**********************************************************************
  252. * Function: BrowseDlgProc
  253. *
  254. * Purpose: This dialog procedure is used to correctly initialize
  255. * a browse dialog box based on the type of browsing to be
  256. * performed.
  257. *
  258. * If just a path (folder) is required, hide the file
  259. * related controls that are on the dialog box.
  260. *
  261. * If drive filtering is required, install a custom message
  262. * handler for the drives combo box that will perform the
  263. * filtering.
  264. *
  265. * In: Standard dialog procedure parameters
  266. *
  267. * Out: TRUE if message handle. FALSE if standard processing
  268. * should occur.
  269. **********************************************************************/
  270. UINT_PTR APIENTRY BrowseDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
  271. {
  272. // Don't do anything if this is NOT the init message
  273. if (msg != WM_INITDIALOG)
  274. return (FALSE) ;
  275. // Hide the unneeded file related controls
  276. ShowWindow(GetDlgItem(hdlg, stc2), SW_HIDE) ;
  277. ShowWindow(GetDlgItem(hdlg, stc3), SW_HIDE) ;
  278. ShowWindow(GetDlgItem(hdlg, edt1), SW_HIDE) ;
  279. ShowWindow(GetDlgItem(hdlg, lst1), SW_HIDE) ;
  280. ShowWindow(GetDlgItem(hdlg, cmb1), SW_HIDE) ;
  281. // Do the default initialization too.
  282. return (FALSE) ;
  283. }
  284. // This routine browses for a directory, beginning with the one named in the
  285. // given control. If a directory is selected, the control is appropriately
  286. // updated.
  287. //
  288. // An old style common dialog box is used to do this. There is a function,
  289. // ::SHBrowseForFolder(), that can do this with the new style dialog box but
  290. // I don't think this function is available on all platforms supported by
  291. // the MDT.
  292. void CSelectDestinations::DoDirectoryBrowser(CString& csinitdir)
  293. {
  294. OPENFILENAME ofn ; // Used to send/get info to/from common dlg
  295. char acpath[_MAX_PATH] ; // Path is saved here (or an error message)
  296. char acidir[_MAX_PATH] ; // Initial directory is built here
  297. BOOL brc = FALSE ; // Return code
  298. // Update the contents of csinitdir
  299. UpdateData(TRUE) ;
  300. // Load the open file name structure
  301. ofn.lStructSize = sizeof(ofn) ;
  302. ofn.hwndOwner = m_hWnd ;
  303. ofn.hInstance = GetModuleHandle(_T("MINIDEV.EXE")) ;
  304. ofn.lpstrFilter = ofn.lpstrCustomFilter = NULL ;
  305. ofn.nMaxCustFilter = ofn.nFilterIndex = 0 ;
  306. StringCchCopyA(acpath, CCHOF(acpath), _T("JUNK")) ; // No need to localize this string
  307. ofn.lpstrFile = acpath ;
  308. ofn.nMaxFile = _MAX_PATH ;
  309. ofn.lpstrFileTitle = NULL ;
  310. ofn.nMaxFileTitle = 0 ;
  311. //n = GetWindowText(hParentDrives, acidir, _MAX_PATH) ;
  312. //GetWindowText(hfolder, &acidir, _MAX_PATH) ;
  313. StringCchCopy(acidir, CCHOF(acidir), csinitdir.GetBufferSetLength(256)) ;
  314. csinitdir.ReleaseBuffer() ;
  315. ofn.lpstrInitialDir = acidir ; // Path in parent dialog box
  316. //LoadString(ofn.hInstance, IDS_SELFOLDTITLE, actitle, 64) ;
  317. ofn.lpstrTitle = NULL ;
  318. ofn.Flags = OFN_HIDEREADONLY | OFN_ENABLEHOOK | OFN_NOCHANGEDIR
  319. | OFN_NOTESTFILECREATE | OFN_ENABLETEMPLATE | OFN_NONETWORKBUTTON ;
  320. ofn.lpstrDefExt = NULL ;
  321. ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FILEOPENORD) ;
  322. ofn.lpfnHook = BrowseDlgProc ;
  323. // Display the dialog box. If the user cancels, just return.
  324. if (!GetOpenFileName(&ofn))
  325. return ;
  326. // Take the bogus file name off the path and put the path into the page's
  327. // edit box.
  328. acpath[ofn.nFileOffset - 1] = 0 ;
  329. csinitdir = acpath ;
  330. UpdateData(FALSE) ;
  331. return ;
  332. }
  333. /******************************************************************************
  334. CSelectDestinations::BuildStructure
  335. This private member function establishes the selected directory structure,
  336. if it can, and reports its success or failure as need be.
  337. ******************************************************************************/
  338. BOOL CSelectDestinations::BuildStructure() {
  339. // Verify the directory exists (or can be created) for each of the
  340. // target directories that is enabled.
  341. CProjectRecord& cpr = m_cnpwOwner.Project();
  342. CString csPath;
  343. if (cpr.IsTargetEnabled(Win2000)) {
  344. GetDlgItemText(IDC_W2000Destination, csPath);
  345. // First, make sure that the path the user selected ends with the
  346. // directory "W2K".
  347. // raid 123448
  348. /* CString cspdir, csw2kdir ;
  349. csw2kdir.LoadString(IDS_NewDriverRootDir) ; // R 123448
  350. cspdir = csPath.Right(csw2kdir.GetLength() + 1) ;
  351. csw2kdir = _T("\\") + csw2kdir ;
  352. if (cspdir.CompareNoCase(csw2kdir) != 0) {
  353. csw2kdir = csw2kdir.Right(csw2kdir.GetLength() - 1) ;
  354. cspdir.Format(IDS_BadDestPath, csw2kdir) ;
  355. AfxMessageBox(cspdir, MB_ICONEXCLAMATION) ;
  356. return FALSE ;
  357. } ;
  358. */ // raid 123448
  359. CString csSourcePath;
  360. csSourcePath = cpr.SourceFile().Left(cpr.SourceFile().ReverseFind('\\') );
  361. if (!csPath.CompareNoCase(csSourcePath) || !csPath.CompareNoCase(csSourcePath + "\\") ) {
  362. AfxMessageBox("You have to have different Destination from RC source file",MB_ICONEXCLAMATION );
  363. return FALSE;
  364. } ;
  365. // Continue with rest of directory verifications...
  366. if (!cpr.SetPath(Win2000, csPath) || !cpr.BuildStructure(Win2000)) {
  367. AfxMessageBox(IDS_CannotMakeDirectory);
  368. GetDlgItem(IDC_W2000Destination) -> SetFocus();
  369. return FALSE;
  370. }
  371. }
  372. if (cpr.IsTargetEnabled(WinNT40)) {
  373. GetDlgItemText(IDC_NT40Destination, csPath);
  374. if (!cpr.SetPath(WinNT40, csPath) || !cpr.BuildStructure(WinNT40)) {
  375. AfxMessageBox(IDS_CannotMakeDirectory);
  376. GetDlgItem(IDC_NT40Destination) -> SetFocus();
  377. return FALSE;
  378. }
  379. }
  380. if (cpr.IsTargetEnabled(WinNT3x)) {
  381. GetDlgItemText(IDC_NT3xDestination, csPath);
  382. if (!cpr.SetPath(WinNT3x, csPath) || !cpr.BuildStructure(WinNT3x)) {
  383. AfxMessageBox(IDS_CannotMakeDirectory);
  384. GetDlgItem(IDC_NT3xDestination) -> SetFocus();
  385. return FALSE;
  386. }
  387. }
  388. return TRUE;
  389. }
  390. /******************************************************************************
  391. CSelectDestinations constructor, destructor, DDX routine and message map.
  392. ******************************************************************************/
  393. CSelectDestinations::CSelectDestinations(CNewConvertWizard& cnpwOwner) :
  394. CPropertyPage(CSelectDestinations::IDD), m_cnpwOwner(cnpwOwner) {
  395. //{{AFX_DATA_INIT(CSelectDestinations)
  396. m_csW2KDest = _T("");
  397. //}}AFX_DATA_INIT
  398. }
  399. CSelectDestinations::~CSelectDestinations() {
  400. }
  401. void CSelectDestinations::DoDataExchange(CDataExchange* pDX) {
  402. CPropertyPage::DoDataExchange(pDX);
  403. //{{AFX_DATA_MAP(CSelectDestinations)
  404. DDX_Control(pDX, IDC_BrowseNT3x, m_cbBrowseNT3x);
  405. DDX_Control(pDX, IDC_BrowseNT40, m_cbBrowseNT40);
  406. DDX_Control(pDX, IDC_BrowseW2000, m_cbBrowseW2000);
  407. DDX_Text(pDX, IDC_W2000Destination, m_csW2KDest);
  408. //}}AFX_DATA_MAP
  409. }
  410. BEGIN_MESSAGE_MAP(CSelectDestinations, CPropertyPage)
  411. //{{AFX_MSG_MAP(CSelectDestinations)
  412. ON_BN_CLICKED(IDC_BrowseNT40, OnBrowseNT40)
  413. ON_BN_CLICKED(IDC_BrowseW2000, OnBrowseW2000)
  414. ON_BN_CLICKED(IDC_BrowseNT3x, OnBrowseNT3x)
  415. //}}AFX_MSG_MAP
  416. END_MESSAGE_MAP()
  417. /////////////////////////////////////////////////////////////////////////////
  418. // CSelectDestinations message handlers
  419. BOOL CSelectDestinations::OnInitDialog() {
  420. CPropertyPage::OnInitDialog();
  421. // Place the browser Icon in the Win2K button
  422. HICON hiArrow = LoadIcon(AfxGetResourceHandle(),
  423. MAKEINTRESOURCE(IDI_BrowseArrow));
  424. m_cbBrowseW2000.SetIcon(hiArrow);
  425. #if 0
  426. m_cbBrowseNT40.SetIcon(hiArrow);
  427. m_cbBrowseNT3x.SetIcon(hiArrow);
  428. #else
  429. m_cbBrowseNT40.ShowWindow(SW_HIDE);
  430. m_cbBrowseNT3x.ShowWindow(SW_HIDE);
  431. #endif
  432. return TRUE;
  433. }
  434. // When we are made active, fill in the correct path names. Note that these
  435. // might change as a result of activity on other pages, so we do not just do
  436. // this at init time.
  437. BOOL CSelectDestinations::OnSetActive() {
  438. // Fill in the correct path names
  439. //SetDlgItemText(IDC_W2000Destination,
  440. // m_cnpwOwner.Project().TargetPath(Win2000));
  441. m_csW2KDest = m_cnpwOwner.Project().TargetPath(Win2000) ;
  442. SetDlgItemText(IDC_NT40Destination,
  443. m_cnpwOwner.Project().TargetPath(WinNT40));
  444. SetDlgItemText(IDC_NT3xDestination,
  445. m_cnpwOwner.Project().TargetPath(WinNT3x));
  446. SetDlgItemText(IDC_Win95Destination,
  447. m_cnpwOwner.Project().TargetPath(Win95));
  448. // Disable all controls related to non-operative targets
  449. GetDlgItem(IDC_W2000Destination) -> EnableWindow(
  450. m_cnpwOwner.Project().IsTargetEnabled(Win2000));
  451. m_cbBrowseW2000.EnableWindow(
  452. m_cnpwOwner.Project().IsTargetEnabled(Win2000));
  453. GetDlgItem(IDC_NT40Destination) -> EnableWindow(
  454. m_cnpwOwner.Project().IsTargetEnabled(WinNT40));
  455. m_cbBrowseNT40.EnableWindow(
  456. m_cnpwOwner.Project().IsTargetEnabled(WinNT40));
  457. GetDlgItem(IDC_NT3xDestination) -> EnableWindow(
  458. m_cnpwOwner.Project().IsTargetEnabled(WinNT3x));
  459. m_cbBrowseNT3x.EnableWindow(
  460. m_cnpwOwner.Project().IsTargetEnabled(WinNT3x));
  461. // Turn on the back and next buttons.
  462. m_cnpwOwner.SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT) ;
  463. // Initialize controls
  464. UpdateData(FALSE) ;
  465. return CPropertyPage::OnSetActive();
  466. }
  467. void CSelectDestinations::OnBrowseNT3x() {
  468. //DoDirectoryBrowser(IDC_NT3xDestination);
  469. }
  470. void CSelectDestinations::OnBrowseNT40() {
  471. //DoDirectoryBrowser(IDC_NT40Destination);
  472. }
  473. void CSelectDestinations::OnBrowseW2000() {
  474. DoDirectoryBrowser(m_csW2KDest);
  475. }
  476. /******************************************************************************
  477. CSelectDestinations::OnWizardNext
  478. Create the project record, build the destination directories, and begin the
  479. conversion. The conversion is started here because the work that is done
  480. will generate the model information that is displayed on the GPD Selection
  481. page.
  482. Note: The original layout of this function is commented out below. It may
  483. be need if some of the unimplemented/incomplete function in this program is
  484. ever finished.
  485. ******************************************************************************/
  486. LRESULT CSelectDestinations::OnWizardNext()
  487. {
  488. // This might take a while, so...
  489. CWaitCursor cwc;
  490. // Build the directory structure
  491. if (!BuildStructure())
  492. return -1;
  493. CProjectRecord& cpr = m_cnpwOwner.Project();
  494. // Open the conversion logging file.
  495. cpr.OpenConvLogFile() ;
  496. // Loading the original resources is done here because some of this
  497. // info is needed for the GPD selection page.
  498. if (!cpr.LoadResources()) {
  499. // Display error message(s) if the resources could not be loaded.
  500. cpr.CloseConvLogFile() ;
  501. AfxMessageBox(IDP_RCLoadFailed) ;
  502. if (cpr.ThereAreConvErrors()) {
  503. CString csmsg ;
  504. csmsg.Format(IDS_FatalConvErrors, cpr.GetConvLogFileName()) ;
  505. AfxMessageBox(csmsg) ;
  506. } ;
  507. m_cnpwOwner.EndDialog(IDCANCEL) ;
  508. return -1 ;
  509. }
  510. return CPropertyPage::OnWizardNext();
  511. }
  512. /******************************************************************************
  513. CSelectDestinations::OnWizardBack
  514. This handles the response to the back button. We must override the default
  515. handler in the case of a normal conversion, as the default will go back to
  516. the target selection page, and we will go back to the initial page in the
  517. fast-path case.
  518. ******************************************************************************/
  519. LRESULT CSelectDestinations::OnWizardBack() {
  520. return m_cnpwOwner.FastConvert() ?
  521. CFirstNewWizardPage::IDD : CPropertyPage::OnWizardBack();
  522. }
  523. /////////////////////////////////////////////////////////////////////////////
  524. // CRunUniTool property page
  525. CRunUniTool::CRunUniTool(CNewConvertWizard& cnpwOwner) :
  526. CPropertyPage(CRunUniTool::IDD), m_cnpwOwner(cnpwOwner) {
  527. //{{AFX_DATA_INIT(CRunUniTool)
  528. // NOTE: the ClassWizard will add member initialization here
  529. //}}AFX_DATA_INIT
  530. }
  531. CRunUniTool::~CRunUniTool() {
  532. }
  533. void CRunUniTool::DoDataExchange(CDataExchange* pDX) {
  534. CPropertyPage::DoDataExchange(pDX);
  535. //{{AFX_DATA_MAP(CRunUniTool)
  536. // NOTE: the ClassWizard will add DDX and DDV calls here
  537. //}}AFX_DATA_MAP
  538. }
  539. BEGIN_MESSAGE_MAP(CRunUniTool, CPropertyPage)
  540. //{{AFX_MSG_MAP(CRunUniTool)
  541. ON_BN_CLICKED(IDC_RunUniTool, OnRunUniTool)
  542. //}}AFX_MSG_MAP
  543. END_MESSAGE_MAP()
  544. /////////////////////////////////////////////////////////////////////////////
  545. // CRunUniTool message handlers
  546. void CRunUniTool::OnRunUniTool() {
  547. // Not too terribly difficult, really. Invoke UniTool, which resides
  548. // in the same directory we came from. Then wait for the user to close it.
  549. STARTUPINFO si = {sizeof si, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0,
  550. STARTF_FORCEONFEEDBACK, 0, 0, NULL, NULL, NULL, NULL};
  551. PROCESS_INFORMATION pi;
  552. CString csCommand("Unitool ");
  553. csCommand += m_cnpwOwner.Project().SourceFile();
  554. if (!CreateProcess(NULL, const_cast <LPTSTR> ((LPCTSTR) csCommand), NULL,
  555. NULL, FALSE, CREATE_SEPARATE_WOW_VDM, NULL,
  556. m_cnpwOwner.Project().TargetPath(Win95), &si, &pi)) {
  557. TRACE("Failed to run Unitool, reason %d <%X>\r\n", GetLastError(),
  558. GetLastError());
  559. AfxMessageBox(IDS_UnitoolNotRun);
  560. return;
  561. }
  562. CloseHandle(pi.hThread); // We'll wait on the process.
  563. WaitForSingleObject(pi.hProcess, INFINITE);
  564. CloseHandle(pi.hProcess);
  565. }
  566. /******************************************************************************
  567. CRunUniTool::OnSetActive
  568. We never force this to be run, anymore, so just enable both buttons.
  569. ******************************************************************************/
  570. BOOL CRunUniTool::OnSetActive() {
  571. // We need to deactivate the Next button if Unitool has not yet been run
  572. // on this driver.
  573. m_cnpwOwner.SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  574. return CPropertyPage::OnSetActive();
  575. }
  576. /******************************************************************************
  577. CRunUniTool::OnWizardNext
  578. Go right on ahead, unless the RC file isn't translatable...
  579. ******************************************************************************/
  580. LRESULT CRunUniTool::OnWizardNext() {
  581. // One last check- we must be able to load and understand the RC file
  582. // before we proceed.
  583. if (!m_cnpwOwner.Project().LoadResources()) {
  584. AfxMessageBox(IDP_RCLoadFailed);
  585. return -1;
  586. }
  587. return CPropertyPage::OnWizardNext();
  588. }
  589. /////////////////////////////////////////////////////////////////////////////
  590. // CConvertFiles property page
  591. CConvertFiles::CConvertFiles(CNewConvertWizard& cnpwOwner) :
  592. CPropertyPage(CConvertFiles::IDD), m_cnpwOwner(cnpwOwner) {
  593. //{{AFX_DATA_INIT(CConvertFiles)
  594. // NOTE: the ClassWizard will add member initialization here
  595. //}}AFX_DATA_INIT
  596. }
  597. CConvertFiles::~CConvertFiles() {
  598. }
  599. void CConvertFiles::DoDataExchange(CDataExchange* pDX) {
  600. CPropertyPage::DoDataExchange(pDX);
  601. //{{AFX_DATA_MAP(CConvertFiles)
  602. // NOTE: the ClassWizard will add DDX and DDV calls here
  603. //}}AFX_DATA_MAP
  604. }
  605. BEGIN_MESSAGE_MAP(CConvertFiles, CPropertyPage)
  606. //{{AFX_MSG_MAP(CConvertFiles)
  607. ON_BN_CLICKED(IDC_ConvertFiles, OnConvertFiles)
  608. //}}AFX_MSG_MAP
  609. END_MESSAGE_MAP()
  610. /////////////////////////////////////////////////////////////////////////////
  611. // CConvertFiles message handlers
  612. /******************************************************************************
  613. CConvertFiles::OnSetActive
  614. This handler is called whenever the user navigates to where this sheet is
  615. active.
  616. ******************************************************************************/
  617. BOOL CConvertFiles::OnSetActive() {
  618. // If there is no NT GPC work to be done, we can be done with it.
  619. m_cnpwOwner.SetWizardButtons(PSWIZB_BACK |
  620. (m_cnpwOwner.Project().IsTargetEnabled(WinNT3x | WinNT40) ?
  621. 0 : PSWIZB_DISABLEDFINISH));
  622. // Set the radio buttons according to the selected GPD conversions
  623. CheckRadioButton(IDC_Direct, IDC_SpoolerNames,
  624. IDC_Direct + m_cnpwOwner.GPDConvertFlag());
  625. return CPropertyPage::OnSetActive();
  626. }
  627. /******************************************************************************
  628. CConvertFiles::OnConvertFiles
  629. Message handler for the user pressing the Convert Files button.
  630. ******************************************************************************/
  631. void CConvertFiles::OnConvertFiles() {
  632. // This might take a while, so...
  633. CWaitCursor cwc;
  634. // We now need to generate ALL of the necessary files
  635. m_cnpwOwner.GPDConvertFlag(
  636. GetCheckedRadioButton(IDC_Direct, IDC_SpoolerNames) - IDC_Direct);
  637. m_cnpwOwner.Project().GenerateTargets(m_cnpwOwner.GPDConvertFlag());
  638. if (m_cnpwOwner.Project().ConversionsComplete())
  639. m_cnpwOwner.SetWizardButtons(PSWIZB_BACK |
  640. (m_cnpwOwner.Project().IsTargetEnabled(WinNT3x | WinNT40) ?
  641. PSWIZB_NEXT : PSWIZB_FINISH));
  642. }
  643. /******************************************************************************
  644. CConvertFiles::OnKillActive
  645. This is called whenever the page is dismissed. We save the GPD conversion
  646. flag, in case we come back to this page later.
  647. ******************************************************************************/
  648. BOOL CConvertFiles::OnKillActive() {
  649. m_cnpwOwner.GPDConvertFlag(
  650. GetCheckedRadioButton(IDC_Direct, IDC_SpoolerNames) - IDC_Direct);
  651. return CPropertyPage::OnKillActive();
  652. }
  653. /////////////////////////////////////////////////////////////////////////////
  654. // CRunNTGPC property page
  655. CRunNTGPC::CRunNTGPC(CNewConvertWizard &cnpwOwner) :
  656. CPropertyPage(CRunNTGPC::IDD), m_cnpwOwner(cnpwOwner) {
  657. //{{AFX_DATA_INIT(CRunNTGPC)
  658. // NOTE: the ClassWizard will add member initialization here
  659. //}}AFX_DATA_INIT
  660. }
  661. CRunNTGPC::~CRunNTGPC() {
  662. }
  663. void CRunNTGPC::DoDataExchange(CDataExchange* pDX) {
  664. CPropertyPage::DoDataExchange(pDX);
  665. //{{AFX_DATA_MAP(CRunNTGPC)
  666. // NOTE: the ClassWizard will add DDX and DDV calls here
  667. //}}AFX_DATA_MAP
  668. }
  669. BEGIN_MESSAGE_MAP(CRunNTGPC, CPropertyPage)
  670. //{{AFX_MSG_MAP(CRunNTGPC)
  671. ON_BN_CLICKED(IDC_RunNtGpcEdit, OnRunNtGpcEdit)
  672. //}}AFX_MSG_MAP
  673. END_MESSAGE_MAP()
  674. /////////////////////////////////////////////////////////////////////////////
  675. // CRunNTGPC message handlers
  676. void CRunNTGPC::OnRunNtGpcEdit() {
  677. // We only hit this step if we are building for NT 3.x or 4.0, so see
  678. // which it is.
  679. CProjectRecord& cprThis = m_cnpwOwner.Project();
  680. UINT ufEdit = cprThis.IsTargetEnabled(WinNT3x) ? WinNT3x : WinNT40;
  681. // Not too terribly difficult, really. Invoke the editor, which resides
  682. // in the same directory we came from. Wait for the user to close it.
  683. STARTUPINFO si = {sizeof si, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0,
  684. STARTF_FORCEONFEEDBACK, 0, 0, NULL, NULL, NULL, NULL};
  685. PROCESS_INFORMATION pi;
  686. CString csCommand("NTGPCEdt ");
  687. csCommand += cprThis.RCName(ufEdit);
  688. if (!CreateProcess(NULL, const_cast <LPTSTR> ((LPCTSTR) csCommand), NULL,
  689. NULL, FALSE, CREATE_SEPARATE_WOW_VDM, NULL,
  690. m_cnpwOwner.Project().TargetPath(ufEdit), &si, &pi)) {
  691. TRACE("Failed to run NTGPCEdt, reason %d <%X>\r\n", GetLastError(),
  692. GetLastError());
  693. AfxMessageBox(IDS_UnitoolNotRun);
  694. return;
  695. }
  696. CloseHandle(pi.hThread); // We'll wait on the process.
  697. WaitForSingleObject(pi.hProcess, INFINITE);
  698. CloseHandle(pi.hProcess);
  699. // Copy the NT GPC file, if necessary}
  700. if (ufEdit == WinNT3x && cprThis.IsTargetEnabled(WinNT40))
  701. CopyFile(cprThis.TargetPath(WinNT3x) + _TEXT("\\NT.GPC"),
  702. cprThis.TargetPath(WinNT40) + _TEXT("\\NT.GPC"), FALSE);
  703. m_cnpwOwner.SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH);
  704. m_cnpwOwner.Project().OldStuffDone();
  705. }
  706. BOOL CRunNTGPC::OnSetActive() {
  707. m_cnpwOwner.SetWizardButtons(PSWIZB_BACK |
  708. (m_cnpwOwner.Project().NTGPCCompleted() ?
  709. PSWIZB_FINISH : PSWIZB_DISABLEDFINISH));
  710. return CPropertyPage::OnSetActive();
  711. }
  712. /////////////////////////////////////////////////////////////////////////////
  713. // CMapCodePages property page
  714. CMapCodePages::CMapCodePages(CNewConvertWizard& cnpwOwner) :
  715. CPropertyPage(CMapCodePages::IDD), m_cnpwOwner(cnpwOwner) {
  716. //{{AFX_DATA_INIT(CMapCodePages)
  717. // NOTE: the ClassWizard will add member initialization here
  718. //}}AFX_DATA_INIT
  719. }
  720. CMapCodePages::~CMapCodePages() {
  721. }
  722. void CMapCodePages::DoDataExchange(CDataExchange* pDX) {
  723. CPropertyPage::DoDataExchange(pDX);
  724. //{{AFX_DATA_MAP(CMapCodePages)
  725. DDX_Control(pDX, IDC_TableToPage, m_clbMapping);
  726. //}}AFX_DATA_MAP
  727. }
  728. BEGIN_MESSAGE_MAP(CMapCodePages, CPropertyPage)
  729. //{{AFX_MSG_MAP(CMapCodePages)
  730. ON_BN_CLICKED(IDC_ChangeCodePage, OnChangeCodePage)
  731. ON_LBN_DBLCLK(IDC_TableToPage, OnChangeCodePage)
  732. //}}AFX_MSG_MAP
  733. END_MESSAGE_MAP()
  734. /////////////////////////////////////////////////////////////////////////////
  735. // CMapCodePages message handlers
  736. BOOL CMapCodePages::OnSetActive() {
  737. m_cnpwOwner.SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  738. m_clbMapping.ResetContent();
  739. for (unsigned u = 0; u < m_cnpwOwner.Project().MapCount(); u++) {
  740. CGlyphMap& cgm = m_cnpwOwner.Project().GlyphMap(u);
  741. int id = m_clbMapping.AddString(cgm.Name() + _TEXT("->") +
  742. cgm.PageName(0));
  743. m_clbMapping.SetItemData(id, u);
  744. }
  745. m_clbMapping.SetCurSel(0);
  746. return CPropertyPage::OnSetActive();
  747. }
  748. /******************************************************************************
  749. CMapCodePages::OnChangeCodePaage
  750. Response to the Change Code Page button. Invoke the change code page dialog,
  751. and pass the new selection to the underlying glyph map. Update the info in
  752. list, too...
  753. ******************************************************************************/
  754. void CMapCodePages::OnChangeCodePage() {
  755. int idSel = m_clbMapping.GetCurSel();
  756. if (idSel < 0)
  757. return;
  758. unsigned uidTable = (unsigned) m_clbMapping.GetItemData(idSel) ;
  759. CGlyphMap& cgm = m_cnpwOwner.Project().GlyphMap(uidTable);
  760. CSelectCodePage cscp(this, cgm.Name(), cgm.PageID(0));
  761. if (cscp.DoModal() == IDOK) {
  762. cgm.SetDefaultCodePage(cscp.SelectedCodePage());
  763. // Update the control- alas, this means filling it all in.
  764. m_clbMapping.ResetContent();
  765. for (unsigned u = 0; u < m_cnpwOwner.Project().MapCount(); u++) {
  766. CGlyphMap& cgm = m_cnpwOwner.Project().GlyphMap(u);
  767. int id = m_clbMapping.AddString(cgm.Name() + _TEXT("->") +
  768. cgm.PageName(0));
  769. m_clbMapping.SetItemData(id, u);
  770. if (u == uidTable)
  771. m_clbMapping.SetCurSel(id);
  772. }
  773. }
  774. }
  775. LRESULT CMapCodePages::OnWizardNext() {
  776. // If this fails, it will report why via a message box.
  777. CWaitCursor cwc; // Just in case this takes a while!
  778. return m_cnpwOwner.Project().LoadFontData() ? 0 : -1;
  779. }
  780. /******************************************************************************
  781. CSelectCodePage class
  782. This class implements a dialog which is used in several places where
  783. selection of a code page is desired.
  784. ******************************************************************************/
  785. /******************************************************************************
  786. CSelectCodePage::CSelectCodePage
  787. The constructor for this class builds an array of the mapped code page names
  788. from the CCodePageInformation class.
  789. ******************************************************************************/
  790. CSelectCodePage::CSelectCodePage(CWnd* pParent, CString csName,
  791. unsigned uidCurrent)
  792. : CDialog(CSelectCodePage::IDD, pParent) {
  793. //{{AFX_DATA_INIT(CSelectCodePage)
  794. // NOTE: the ClassWizard will add member initialization here
  795. //}}AFX_DATA_INIT
  796. m_csName = csName;
  797. m_uidCurrent = uidCurrent;
  798. CCodePageInformation ccpi;
  799. ccpi.Mapped(m_cdaPages);
  800. }
  801. void CSelectCodePage::DoDataExchange(CDataExchange* pDX) {
  802. CDialog::DoDataExchange(pDX);
  803. //{{AFX_DATA_MAP(CSelectCodePage)
  804. DDX_Control(pDX, IDC_SupportedPages, m_clbPages);
  805. //}}AFX_DATA_MAP
  806. }
  807. /******************************************************************************
  808. CSelectCodePage::GetCodePageName
  809. This returns the name of the selected code page.
  810. ******************************************************************************/
  811. CString CSelectCodePage::GetCodePageName() const {
  812. CCodePageInformation ccpi;
  813. return ccpi.Name(m_uidCurrent);
  814. }
  815. /******************************************************************************
  816. CSelectCodePage::Exclude
  817. This member function receives a list of code pages which are not to be
  818. displayed in the selection list.
  819. ******************************************************************************/
  820. void CSelectCodePage::Exclude(CDWordArray& cdaPariah) {
  821. for (int i = 0; i < cdaPariah.GetSize(); i++)
  822. for (int j = 0; j < m_cdaPages.GetSize(); j++)
  823. if (cdaPariah[i] == m_cdaPages[j]) {
  824. m_cdaPages.RemoveAt(j);
  825. break;
  826. }
  827. }
  828. /******************************************************************************
  829. CSelectCodePage::LimitTo
  830. This member receives a list of the pages to select- this list supersedes the
  831. list of mapped tables we began with.
  832. ******************************************************************************/
  833. void CSelectCodePage::LimitTo(CDWordArray& cdaPages) {
  834. if (!cdaPages.GetSize())
  835. return;
  836. m_cdaPages.Copy(cdaPages);
  837. }
  838. BEGIN_MESSAGE_MAP(CSelectCodePage, CDialog)
  839. //{{AFX_MSG_MAP(CSelectCodePage)
  840. ON_LBN_SELCHANGE(IDC_SupportedPages, OnSelchangeSupportedPages)
  841. ON_LBN_DBLCLK(IDC_SupportedPages, OnDblclkSupportedPages)
  842. //}}AFX_MSG_MAP
  843. END_MESSAGE_MAP()
  844. /////////////////////////////////////////////////////////////////////////////
  845. // CSelectCodePage message handlers
  846. BOOL CSelectCodePage::OnInitDialog() {
  847. CDialog::OnInitDialog();
  848. CString csTemp;
  849. GetWindowText(csTemp);
  850. csTemp += _TEXT(" ") + m_csName;
  851. SetWindowText(csTemp);
  852. CCodePageInformation ccpi;
  853. for (int i = 0; i < m_cdaPages.GetSize(); i++) {
  854. int id = m_clbPages.AddString(ccpi.Name(m_cdaPages[i]));
  855. m_clbPages.SetItemData(id, m_cdaPages[i]);
  856. }
  857. // The one to select is the current one
  858. for (i = 0; i < m_cdaPages.GetSize(); i++)
  859. if (m_uidCurrent == m_clbPages.GetItemData(i))
  860. break;
  861. if (i < m_cdaPages.GetSize())
  862. m_clbPages.SetCurSel(i);
  863. else {
  864. m_uidCurrent = (unsigned) m_clbPages.GetItemData(0);
  865. m_clbPages.SetCurSel(0);
  866. }
  867. return TRUE; // return TRUE unless you set the focus to a control
  868. }
  869. // When a new code page is selected, record its identity.
  870. void CSelectCodePage::OnSelchangeSupportedPages() {
  871. // Determine what the newly selected page is.
  872. int idCurrent = m_clbPages.GetCurSel();
  873. if (idCurrent < 0)
  874. return;
  875. m_uidCurrent = (unsigned) m_clbPages.GetItemData(idCurrent);
  876. }
  877. void CSelectCodePage::OnDblclkSupportedPages() {
  878. CDialog::OnOK();
  879. }
  880. /////////////////////////////////////////////////////////////////////////////
  881. // CGPDSelection property page
  882. CGPDSelection::CGPDSelection(CNewConvertWizard& cnpwOwner) :
  883. CPropertyPage(CGPDSelection::IDD), m_cnpwOwner(cnpwOwner),
  884. m_ceclbGPDInfo(&m_ceModelName, &m_cecebFileName),
  885. m_cecebFileName(&m_ceclbGPDInfo)
  886. {
  887. //{{AFX_DATA_INIT(CGPDSelection)
  888. // NOTE: the ClassWizard will add member initialization here
  889. //}}AFX_DATA_INIT
  890. // Initially, the Select All / Deselect All button is set to Select All.
  891. m_bBtnStateIsSelect = true ;
  892. }
  893. CGPDSelection::~CGPDSelection()
  894. {
  895. }
  896. void CGPDSelection::DoDataExchange(CDataExchange* pDX)
  897. {
  898. CPropertyPage::DoDataExchange(pDX);
  899. //{{AFX_DATA_MAP(CGPDSelection)
  900. DDX_Control(pDX, IDC_GPDSelBtn, m_cbGPDSelBtn);
  901. DDX_Control(pDX, IDC_ECValue, m_cecebFileName);
  902. DDX_Control(pDX, IDC_ECName, m_ceModelName);
  903. DDX_Control(pDX, IDC_ECList, m_ceclbGPDInfo);
  904. //}}AFX_DATA_MAP
  905. }
  906. BEGIN_MESSAGE_MAP(CGPDSelection, CPropertyPage)
  907. //{{AFX_MSG_MAP(CGPDSelection)
  908. ON_BN_CLICKED(IDC_GPDSelBtn, OnGPDSelBtn)
  909. //}}AFX_MSG_MAP
  910. END_MESSAGE_MAP()
  911. /////////////////////////////////////////////////////////////////////////////
  912. // CGPDSelection message handlers
  913. BOOL CGPDSelection::OnSetActive()
  914. {
  915. m_cnpwOwner.SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH) ;
  916. // Get the current GPD model names and file names.
  917. CProjectRecord& cpr = m_cnpwOwner.Project() ;
  918. CStringArray csamodels, csafiles ;
  919. if (!cpr.GetGPDModelInfo(&csamodels, &csafiles)) {
  920. AfxMessageBox(IDS_GPDSelInitFailed) ;
  921. return FALSE ;
  922. } ;
  923. // Load the Edit Control with the data collected above and do the rest of
  924. // the initialization that is needed.
  925. //if (!m_ceclbGPDInfo.Init(csamodels, csafiles, 110)) {
  926. if (!m_ceclbGPDInfo.Init(csamodels, csafiles, 120)) {
  927. AfxMessageBox(IDS_GPDSelInitFailed) ;
  928. return FALSE ;
  929. } ;
  930. return CPropertyPage::OnSetActive() ;
  931. }
  932. BOOL CGPDSelection::OnWizardFinish()
  933. {
  934. // Save and verify the GPD info. Return 0 if this fails so that the
  935. // wizard won't close.
  936. if (!GPDInfoSaveAndVerify(true))
  937. return 0 ;
  938. // This might take a while, so...
  939. CWaitCursor cwc ;
  940. CProjectRecord& cpr = m_cnpwOwner.Project() ;
  941. // Continue with the conversion process. Start by loading the PFMs and
  942. // CTTs.
  943. if (!cpr.LoadFontData()) {
  944. // Display error message(s) if the fonts could not be loaded.
  945. cpr.CloseConvLogFile() ;
  946. if (cpr.ThereAreConvErrors()) {
  947. CString csmsg ;
  948. csmsg.Format(IDS_FatalConvErrors, cpr.GetConvLogFileName()) ;
  949. AfxMessageBox(csmsg) ;
  950. } ;
  951. m_cnpwOwner.EndDialog(IDCANCEL) ;
  952. return TRUE ;
  953. }
  954. // We now need to generate ALL of the necessary files
  955. BOOL brc = cpr.GenerateTargets(m_cnpwOwner.GPDConvertFlag()) ;
  956. // Close the conversion logging file.
  957. cpr.CloseConvLogFile() ;
  958. // Tell the user if some conversion errors were logged.
  959. if (cpr.ThereAreConvErrors()) {
  960. CString csmsg ;
  961. csmsg.Format(IDS_ConvErrors, cpr.GetConvLogFileName()) ;
  962. AfxMessageBox(csmsg) ;
  963. } ;
  964. // Handle the failure of the GenerateTargets step
  965. if (!brc) {
  966. m_cnpwOwner.EndDialog(IDCANCEL) ;
  967. return TRUE ;
  968. } ;
  969. // Copy standard file to the new driver's directory
  970. try {
  971. CString cssrc, csdest ;
  972. cssrc = ThisApp().GetAppPath() + _T("stdnames.gpd") ;
  973. csdest = cpr.GetW2000Path() + _T("\\") + _T("stdnames.gpd") ;
  974. CopyFile(cssrc, csdest, FALSE) ;
  975. //cssrc = ThisApp().GetAppPath() + _T("common.rc") ;
  976. //csdest = cpr.GetW2000Path() + _T("\\") + _T("common.rc") ;
  977. //CopyFile(cssrc, csdest, FALSE) ;
  978. }
  979. catch (CException *pce) {
  980. pce->ReportError() ;
  981. pce->Delete() ;
  982. return FALSE ;
  983. }
  984. return cpr.ConversionsComplete() ;
  985. }
  986. LRESULT CGPDSelection::OnWizardBack()
  987. {
  988. // Save the GPD info. Return -1 if this fails so that the wizard page
  989. // won't change. (Probably won't fail.)
  990. if (!GPDInfoSaveAndVerify(false))
  991. return -1 ;
  992. return CPropertyPage::OnWizardBack() ;
  993. }
  994. bool CGPDSelection::GPDInfoSaveAndVerify(bool bverifydata)
  995. {
  996. // Get the file names from the Edit Control.
  997. CStringArray csafiles ;
  998. m_ceclbGPDInfo.GetGPDInfo(csafiles) ;
  999. // If verification is requested and there are no selected files, ask the
  1000. // user if that is what he wants. If no, return false to indicate that
  1001. // GPD selection should continue.
  1002. if (bverifydata) {
  1003. int numelts = (int)csafiles.GetSize() ;
  1004. for (int n = 0 ; n < numelts ; n++) {
  1005. if (!csafiles[n].IsEmpty())
  1006. break ;
  1007. } ;
  1008. if (n >= numelts) {
  1009. n = AfxMessageBox(IDS_NoGPDsPrompt, MB_YESNO | MB_ICONQUESTION) ;
  1010. if (n == IDYES)
  1011. return 0 ;
  1012. } ;
  1013. } ;
  1014. // Send the GPD file names back to the driver conversion code and verify
  1015. // them if requested. If the verification fails, select the offending
  1016. // list box entry and return false to indicate that verification failed.
  1017. CProjectRecord& cpr = m_cnpwOwner.Project() ;
  1018. int nidx = cpr.SaveVerGPDFNames(csafiles, bverifydata) ;
  1019. if (nidx >= 0) {
  1020. m_ceclbGPDInfo.SelectLBEntry(nidx) ;
  1021. return false ;
  1022. } ;
  1023. // All went well so...
  1024. return true ;
  1025. }
  1026. void CGPDSelection::OnGPDSelBtn()
  1027. {
  1028. // Get the file names and model names from the Edit Control.
  1029. CStringArray csafiles, csamodels ;
  1030. m_ceclbGPDInfo.GetGPDInfo(csafiles, &csamodels) ;
  1031. // Models are selected by generating a file name for them. Select all
  1032. // unselected models when appropriate...
  1033. if (m_bBtnStateIsSelect) {
  1034. CProjectRecord& cpr = m_cnpwOwner.Project() ;
  1035. cpr.GenerateGPDFileNames(csamodels, csafiles) ;
  1036. // ...Otherwise, deselect all models by deleting their file names
  1037. } else {
  1038. int numelts = (int)csafiles.GetSize() ;
  1039. for (int n = 0 ; n < numelts ; n++)
  1040. csafiles[n] = _T("") ;
  1041. } ;
  1042. // Reinitialize the edit control with the modified data.
  1043. m_ceclbGPDInfo.Init(csamodels, csafiles, 120) ;
  1044. // Change the button caption and the button state flag
  1045. CString cscaption ;
  1046. cscaption.LoadString((m_bBtnStateIsSelect) ? IDS_DeselectAll : IDS_SelectAll) ;
  1047. m_cbGPDSelBtn.SetWindowText(cscaption) ;
  1048. m_bBtnStateIsSelect = !m_bBtnStateIsSelect ;
  1049. }
  1050. /////////////////////////////////////////////////////////////////////////////
  1051. // CDefaultCodePageSel property page
  1052. CDefaultCodePageSel::CDefaultCodePageSel(CNewConvertWizard& cnpwOwner) :
  1053. CPropertyPage(CDefaultCodePageSel::IDD), m_cnpwOwner(cnpwOwner),
  1054. bInitialized(false)
  1055. {
  1056. //{{AFX_DATA_INIT(CDefaultCodePageSel)
  1057. // NOTE: the ClassWizard will add member initialization here
  1058. //}}AFX_DATA_INIT
  1059. }
  1060. CDefaultCodePageSel::~CDefaultCodePageSel()
  1061. {
  1062. }
  1063. void CDefaultCodePageSel::DoDataExchange(CDataExchange* pDX)
  1064. {
  1065. CPropertyPage::DoDataExchange(pDX);
  1066. //{{AFX_DATA_MAP(CDefaultCodePageSel)
  1067. DDX_Control(pDX, IDC_CodePageList, m_clbCodePages);
  1068. //}}AFX_DATA_MAP
  1069. }
  1070. BEGIN_MESSAGE_MAP(CDefaultCodePageSel, CPropertyPage)
  1071. //{{AFX_MSG_MAP(CDefaultCodePageSel)
  1072. // NOTE: the ClassWizard will add message map macros here
  1073. //}}AFX_MSG_MAP
  1074. END_MESSAGE_MAP()
  1075. /////////////////////////////////////////////////////////////////////////////
  1076. // CDefaultCodePageSel message handlers
  1077. BOOL CDefaultCodePageSel::OnSetActive()
  1078. {
  1079. // Do nothing if the page has been activated already.
  1080. // raid 118881
  1081. m_cnpwOwner.SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  1082. if (bInitialized) // if back from the next property
  1083. return CPropertyPage::OnSetActive() ;
  1084. // Find out how many code pages are installed on the machine.
  1085. CCodePageInformation ccpi ;
  1086. unsigned unumcps = ccpi.InstalledCount() ;
  1087. // Get the installed code page numbers and load them into the code page
  1088. // list box.
  1089. DWORD dwcp, dwdefcp ;
  1090. dwdefcp = GetACP() ;
  1091. TCHAR accp[32] ;
  1092. int n ; ;
  1093. for (unsigned u = 0 ; u < unumcps ; u++) {
  1094. dwcp = ccpi.Installed(u) ;
  1095. // There are 3 code pages that seem to make MultiByteToWideChar() to
  1096. // fail. Don't let the user choose one of those code pages unless
  1097. // he knows the secret password (ie, undocument command line switch
  1098. // 'CP').
  1099. if (ThisApp().m_bExcludeBadCodePages)
  1100. if (dwcp == 1361 || dwcp == 28595 || dwcp == 28597)
  1101. continue ;
  1102. StringCchPrintf(accp, CCHOF(accp), _T("%5d"), dwcp) ;
  1103. n = m_clbCodePages.AddString(accp) ;
  1104. if (dwcp == dwdefcp)
  1105. m_clbCodePages.SetCurSel(n) ;
  1106. } ;
  1107. // Everything is set up now so call the base routine.
  1108. bInitialized = true ;
  1109. return CPropertyPage::OnSetActive() ;
  1110. }
  1111. LRESULT CDefaultCodePageSel::OnWizardNext()
  1112. {
  1113. // Get the index of the currently selected list box item.
  1114. int nsel ;
  1115. if ((nsel = m_clbCodePages.GetCurSel()) == LB_ERR) {
  1116. AfxMessageBox(IDS_MustSelCP, MB_ICONINFORMATION) ;
  1117. return -1 ;
  1118. } ;
  1119. // Get the selected list box string.
  1120. CString cs ;
  1121. m_clbCodePages.GetText(nsel, cs) ;
  1122. // Turn the string into a number and convert the number into the
  1123. // corresponding predefined GTT code for Far East code pages when
  1124. // applicable.
  1125. short scp = (short) atoi(cs) ;
  1126. DWORD dwcp = (DWORD) scp ; // Keep copy of real CP
  1127. switch (scp) {
  1128. case 932:
  1129. scp = -17 ;
  1130. break ;
  1131. case 936:
  1132. scp = -16 ;
  1133. break ;
  1134. case 949:
  1135. scp = -18 ;
  1136. break ;
  1137. case 950:
  1138. scp = -10 ;
  1139. break ;
  1140. } ;
  1141. // Save the default "code page" number in the project class instance.
  1142. CProjectRecord& cpr = m_cnpwOwner.Project() ;
  1143. cpr.SetDefaultCodePageNum(dwcp) ; // Save real CP number first
  1144. dwcp = (DWORD) scp ;
  1145. cpr.SetDefaultCodePage(dwcp) ;
  1146. // All went well so...
  1147. return CPropertyPage::OnWizardNext();
  1148. }