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.

1283 lines
38 KiB

  1. // NewTProject.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Minidev.h"
  5. #include "utility.h"
  6. #include "projnode.h"
  7. #include "gpdfile.h"
  8. #include <gpdparse.h>
  9. #include "comctrls.h"
  10. #include "newproj.h"
  11. #include "newcomp.h"
  12. #include "nconvert.h"
  13. #include "nproject.h"
  14. //#include "nprjwiz.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CNewProject dialog
  22. TCHAR *TName[] = {_T("PCL 3"),_T("PCL 5e"),_T("HPGL 2"),_T("PCL 6"),_T("ESC / 2") } ;
  23. DWORD TID[] = {100,101,102,103,104 } ;
  24. TCHAR *TFileName[] = {_T("pcl3.gpd"),_T("pcl5e.gpd"),_T("hpgl2.gpd"),_T("pcl6.gpd"),_T("escp2.gpd")} ;
  25. TCHAR *AddedGpd[] = { _T("pjl.gpd"),_T("p6disp.gpd"),_T("pclxl.gpd"),_T("p6font.gpd") } ;
  26. DWORD AddID [] = {110,111,112,113} ;
  27. //IMPLEMENT_DYNCREATE(CNewProject, CPropertyPage)
  28. IMPLEMENT_SERIAL(CNewProject, CPropertyPage, 0)
  29. CNewProject::CNewProject()
  30. : CPropertyPage(CNewProject::IDD)
  31. {
  32. //{{AFX_DATA_INIT(CNewProject)
  33. m_csPrjname = _T("");
  34. m_csPrjpath = _T("");
  35. m_cstname = _T("");
  36. m_cstpath = _T("");
  37. //}}AFX_DATA_INIT
  38. unsigned uTemplate = sizeof(TName)/sizeof(TName[0]) ;
  39. // this routine run when this called for the first time in MDT program
  40. // project wizard are serialized.
  41. if (!m_csaTlst.GetSize() ){
  42. for(unsigned i = 0 ; i < uTemplate ; i ++ )
  43. m_csaTlst.Add(TName[i]) ;
  44. CWinApp* pApp = AfxGetApp();
  45. CString cshelppath = pApp->m_pszHelpFilePath;
  46. CString csAdded = cshelppath.Left(cshelppath.ReverseFind('\\') ) ;
  47. csAdded += _T("\\Template\\*.gpd") ;
  48. CFileFind cff; // BUG_BUG :: code clean below.
  49. WIN32_FIND_DATA fd;
  50. HANDLE hFile = FindFirstFile(csAdded,&fd ) ;
  51. if (INVALID_HANDLE_VALUE != hFile ) {
  52. csAdded = csAdded.Left(csAdded.ReverseFind('\\') + 1) ;
  53. CString cstname = fd.cFileName ;
  54. cstname = cstname.Left(cstname.ReverseFind(_T('.') ) ) ;
  55. m_csaTlst.Add(cstname ) ;
  56. m_cmstsTemplate[m_csaTlst[i++]] = csAdded + fd.cFileName ;
  57. while (FindNextFile(hFile,&fd) ) {
  58. CString cstname = fd.cFileName ;
  59. cstname = cstname.Left(cstname.ReverseFind(_T('.') ) ) ;
  60. m_csaTlst.Add(cstname ) ;
  61. m_cmstsTemplate[m_csaTlst[i++]] = csAdded + fd.cFileName ;
  62. }
  63. } ;
  64. } ;
  65. } ;
  66. void CNewProject::DoDataExchange(CDataExchange* pDX)
  67. {
  68. CPropertyPage::DoDataExchange(pDX);
  69. //{{AFX_DATA_MAP(CNewProject)
  70. DDX_Control(pDX, IDC_DirBrowser, m_cbLocprj);
  71. DDX_Control(pDX, IDC_CHECK_ADD, m_cbAddT);
  72. DDX_Control(pDX,IDC_LIST_ProjectTemplate,m_clcTemplate) ;
  73. DDX_Text(pDX, IDC_EDIT_NPRJNAME, m_csPrjname);
  74. DDX_Text(pDX, IDC_EDIT_NPRJLOC, m_csPrjpath);
  75. DDX_Text(pDX, IDC_EDIT_AddTName, m_cstname);
  76. DDX_Text(pDX, IDC_EDIT_AddTPath, m_cstpath);
  77. //}}AFX_DATA_MAP
  78. }
  79. BEGIN_MESSAGE_MAP(CNewProject, CPropertyPage)
  80. //{{AFX_MSG_MAP(CNewProject)
  81. ON_BN_CLICKED(IDC_Search_PRJ, OnGpdBrowser)
  82. ON_BN_CLICKED(IDC_DirBrowser, OnDirBrowser)
  83. ON_BN_CLICKED(IDC_CHECK_ADD, OnCheckAdd)
  84. ON_BN_CLICKED(IDC_AddTemplate, OnAddTemplate)
  85. ON_EN_CHANGE(IDC_EDIT_NPRJNAME, OnChangeEditPrjName)
  86. ON_EN_CHANGE(IDC_EDIT_NPRJLOC, OnChangeEditPrjLoc)
  87. ON_NOTIFY(NM_CLICK, IDC_LIST_ProjectTemplate, OnClickListTemplate)
  88. ON_NOTIFY(NM_DBLCLK, IDC_LIST_ProjectTemplate, OnDblclkListTemplate)
  89. //}}AFX_MSG_MAP
  90. END_MESSAGE_MAP()
  91. /////////////////////////////////////////////////////////////////////////////
  92. // CNewProject message handlers
  93. /********************************************************************************
  94. void CNewProject::OnGpdBrowser()
  95. Look for template file browser (*.gpd)
  96. *********************************************************************************/
  97. void CNewProject::OnGpdBrowser()
  98. {
  99. UpdateData() ;
  100. CString csFilter = _T("Template file(*.gpd)|*.gpd||") ;
  101. CString csExtension = _T(".GPD") ;
  102. CFileDialog cfd(TRUE, csExtension, NULL,
  103. OFN_HIDEREADONLY | OFN_FILEMUSTEXIST ,csFilter);
  104. if (cfd.DoModal() == IDOK) {
  105. m_cstpath = cfd.GetPathName() ;
  106. UpdateData(FALSE) ;
  107. } ;
  108. }
  109. /********************************************************************************
  110. void CNewProject::OnDirBrowser()
  111. 1. locate the directory of project : under this \ufm, \gtt will be created .
  112. 2.
  113. *********************************************************************************/
  114. void CNewProject::OnDirBrowser()
  115. {
  116. /*
  117. BROWSEINFO brif = {0} ;
  118. LPITEMIDLIST pidlRoot = NULL;
  119. LPITEMIDLIST pidlSelected = NULL;
  120. LPMALLOC pMalloc = NULL ;
  121. char * pszPath = new char[256] ;
  122. SHGetMalloc(&pMalloc) ;
  123. // SHGetSpecialFolderLocation(m_hWnd,CSIDL_RECENT,&pidlRoot) ;
  124. brif.hwndOwner = m_hWnd ;
  125. brif.pidlRoot = pidlRoot ;
  126. brif.pszDisplayName = new char[256] ;
  127. brif.lpszTitle = _T("Set Directory") ;
  128. brif.ulFlags = 0 ;
  129. brif.lpfn = NULL ;
  130. pidlSelected = SHBrowseForFolder(&brif) ;
  131. SHGetPathFromIDList(pidlSelected,pszPath) ;
  132. */
  133. OPENFILENAME ofn ; // Used to send/get info to/from common dlg
  134. char acpath[_MAX_PATH] ; // Path is saved here (or an error message)
  135. // char acidir[_MAX_PATH] ; // Initial directory is built here
  136. BOOL brc = FALSE ; // Return code
  137. // Update the contents of csinitdir
  138. UpdateData(TRUE) ;
  139. // Load the open file name structure
  140. ofn.lStructSize = sizeof(ofn) ;
  141. ofn.hwndOwner = m_hWnd ;
  142. ofn.hInstance = GetModuleHandle(_T("MINIDEV.EXE")) ;
  143. ofn.lpstrFilter = ofn.lpstrCustomFilter = NULL ;
  144. ofn.nMaxCustFilter = ofn.nFilterIndex = 0 ;
  145. StringCchCopyA(acpath, CCHOF(acpath), _T("JUNK")) ; // No need to localize this string
  146. ofn.lpstrFile = acpath ;
  147. ofn.nMaxFile = _MAX_PATH ;
  148. ofn.lpstrFileTitle = NULL ;
  149. ofn.nMaxFileTitle = 0 ;
  150. ofn.lpstrInitialDir = NULL ; // in parent dialog box
  151. ofn.lpstrTitle = NULL ;
  152. ofn.Flags = OFN_HIDEREADONLY /*| OFN_ENABLEHOOK */| OFN_NOCHANGEDIR
  153. | OFN_NOTESTFILECREATE | OFN_ENABLETEMPLATE | OFN_NONETWORKBUTTON ;
  154. ofn.lpstrDefExt = NULL ;
  155. ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FILEOPENORD) ;
  156. ofn.lpfnHook = NULL ;// BrowseDlgProc ;
  157. // Display the dialog box. If the user cancels, just return.
  158. if (!GetOpenFileName(&ofn))
  159. return ;
  160. // Take the bogus file name off the path and put the path into the page's
  161. // edit box.
  162. acpath[ofn.nFileOffset - 1] = 0 ;
  163. m_csPrjpath = (LPCTSTR) acpath ;
  164. m_csoldPrjpath = m_csPrjpath ;
  165. if ( m_csPrjname.GetLength() != 0)
  166. m_csPrjpath += _T("\\") + m_csPrjname ;
  167. UpdateData(FALSE) ;
  168. /* if (pidlSelected)
  169. pMalloc->Free(pidlSelected) ;
  170. pMalloc->Release() ;
  171. */
  172. }
  173. /********************************************************************************
  174. BOOL CNewProject::OnInitDialog()
  175. ToDo : load the template gpd file and show them to list control box, also disable
  176. add template relevant control
  177. *********************************************************************************/
  178. BOOL CNewProject::OnInitDialog()
  179. {
  180. CDialog::OnInitDialog();
  181. // get PropertySheet pointer
  182. m_pcps = DYNAMIC_DOWNCAST(CPropertySheet,GetOwner() ) ;
  183. // uncheck the check box,
  184. m_cbAddT.SetCheck(false) ;
  185. // disable Add Template Edit box
  186. TCHAR cBuf[256];
  187. GetCurrentDirectory(256,cBuf) ;
  188. m_csPrjpath = cBuf ;
  189. m_csoldPrjpath = m_csPrjpath ;
  190. UpdateData(FALSE);
  191. // initialize the tempalte list with its icon
  192. CImageList* pcil = new CImageList ;
  193. pcil->Create(16,16,ILC_COLOR4,4,1 );
  194. CBitmap cb;
  195. cb.LoadBitmap(IDB_SMALLGLYPH);
  196. for (unsigned j =0; j< (unsigned)m_csaTlst.GetSize(); j++) {
  197. pcil->Add(&cb,RGB(0,0,0) );
  198. }
  199. cb.DeleteObject() ;
  200. m_clcTemplate.SetImageList(pcil,LVSIL_SMALL);
  201. LV_ITEM lvi ;
  202. for(unsigned i = 0 ; i < (unsigned)m_csaTlst.GetSize() ; i ++ ) {
  203. lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM ;
  204. lvi.iItem = i ;
  205. lvi.iSubItem = 0 ;
  206. lvi.pszText = m_csaTlst[i].GetBuffer(m_csaTlst[i].GetLength() ) ;
  207. lvi.iImage = i ;
  208. lvi.lParam = (UINT_PTR)i ;
  209. m_clcTemplate.InsertItem(&lvi) ;
  210. }
  211. // disable unused button
  212. GetDlgItem(IDC_EDIT_AddTName)->EnableWindow(FALSE) ;
  213. GetDlgItem(IDC_EDIT_AddTPath)->EnableWindow(FALSE) ;
  214. GetDlgItem(IDC_AddTemplate)->EnableWindow(FALSE) ;
  215. return TRUE; // return TRUE unless you set the focus to a control
  216. // EXCEPTION: OCX Property Pages should return FALSE
  217. }
  218. /********************************************************************************
  219. BOOL CNewProject::OnSetActive()
  220. *********************************************************************************/
  221. BOOL CNewProject::OnSetActive()
  222. {
  223. SetButton() ;
  224. // UpdateData(FALSE) ;
  225. return CPropertyPage::OnSetActive();
  226. }
  227. /********************************************************************************
  228. CNewProject::OnCheckAdd()
  229. when user check the add template box, it will enable other control
  230. **********************************************************************************/
  231. void CNewProject::OnCheckAdd()
  232. {
  233. CEdit ceTName, ceTPath ;
  234. if ( m_cbAddT.GetCheck() ) {// check the button
  235. GetDlgItem(IDC_EDIT_AddTName)->EnableWindow(TRUE) ;
  236. GetDlgItem(IDC_EDIT_AddTPath)->EnableWindow(TRUE) ;
  237. GetDlgItem(IDC_AddTemplate)->EnableWindow(TRUE) ;
  238. }
  239. else {
  240. GetDlgItem(IDC_EDIT_AddTName)->EnableWindow(FALSE) ;
  241. GetDlgItem(IDC_EDIT_AddTPath)->EnableWindow(FALSE) ;
  242. GetDlgItem(IDC_AddTemplate)->EnableWindow(FALSE) ;
  243. } ;
  244. } ;
  245. /********************************************************************************
  246. void CNewProject::OnAddTemplate()
  247. 1. Add template name to Template list box.
  248. 2. Save template file and its file to mapping variable
  249. ********************************************************************************/
  250. void CNewProject::OnAddTemplate()
  251. {
  252. UpdateData() ;
  253. // check the added template nane is right ?
  254. BOOL bname = FALSE ;
  255. for ( unsigned i = 0 ; i < (unsigned) m_csaTlst.GetSize() ; i++ ) {
  256. CString cstmp = m_csaTlst[i] ;
  257. if (!cstmp.CompareNoCase(m_cstname) ){
  258. bname = TRUE ;
  259. break;
  260. }
  261. } ;
  262. if (m_cstname.GetLength() == 0 || m_cstpath.GetLength() == 0 || bname) {
  263. CString csErr ;
  264. csErr.LoadString(IDS_FailCreateTemplate) ;
  265. AfxMessageBox(csErr,MB_ICONEXCLAMATION) ;
  266. return ;
  267. } ;
  268. // add the template name to its CStrinArray name list and list control.
  269. m_csaTlst.Add(m_cstname) ;
  270. i = PtrToInt(PVOID(m_csaTlst.GetSize()) ) ;
  271. m_clcTemplate.InsertItem(i-1, m_csaTlst[i-1] ) ;
  272. // copy the template file into the template directory, which is under MDT file
  273. // directory\template
  274. // Get the mdt dir.
  275. CWinApp* pApp = AfxGetApp();
  276. CString csRoot = pApp->m_pszHelpFilePath;
  277. csRoot = csRoot.Left(csRoot.ReverseFind('\\') ) ;
  278. csRoot += _T("\\Template") ;
  279. // Create the directory under MDT help file directory if it does not exist
  280. SECURITY_ATTRIBUTES st;
  281. st.nLength = sizeof(SECURITY_ATTRIBUTES);
  282. st.lpSecurityDescriptor = NULL;
  283. st.bInheritHandle = FALSE ;
  284. WIN32_FIND_DATA wfd32 ;
  285. HANDLE hDir = FindFirstFile(csRoot,&wfd32) ;
  286. if (hDir == INVALID_HANDLE_VALUE) {
  287. if (!CreateDirectory(csRoot,&st) ) {
  288. CString csErr ;
  289. csErr.LoadString(IDS_FailCreateTempDir) ;
  290. AfxMessageBox(csErr) ;
  291. return ;
  292. }
  293. } ;
  294. // copy the file, target file name should be template file name for convernience
  295. // when loading the template file.
  296. CString csdst = csRoot + _T('\\') + m_cstname + _T(".GPD") ;
  297. if (!CopyFile(m_cstpath,csdst , TRUE)) {
  298. CString csmsg ;
  299. csmsg.Format(IDS_AddCopyFailed, m_cstpath,
  300. csdst.Left(csdst.GetLength() - 1)) ;
  301. csmsg += csdst ;
  302. AfxMessageBox(csmsg) ;
  303. return ;
  304. };
  305. // add to the collection as its template name and its path
  306. m_cmstsTemplate[m_cstname] = (LPCTSTR)csdst.GetBuffer(256) ;
  307. CString csmsg ;
  308. csmsg.Format(IDS_TemplateCreated, csRoot ) ;
  309. AfxMessageBox(csmsg) ;
  310. }
  311. /***************************************************************************************
  312. void CNewProject::OnChangeEditPrjName()
  313. 1. As user write project name, same name will be written to prject path simultaneously.
  314. ****************************************************************************************/
  315. void CNewProject::OnChangeEditPrjName()
  316. {
  317. // TODO: If this is a RICHEDIT control, the control will not
  318. // send this notification unless you override the CPropertyPage::OnInitDialog()
  319. // function and call CRichEditCtrl().SetEventMask()
  320. // with the ENM_CHANGE flag ORed into the mask.
  321. UpdateData() ;
  322. SetButton() ;
  323. m_csPrjpath = m_csoldPrjpath + _T("\\") + m_csPrjname ;
  324. UpdateData(FALSE) ;
  325. }
  326. /***************************************************************************************
  327. void CNewProject::OnChangeEditPrjLoc()
  328. ****************************************************************************************/
  329. void CNewProject::OnChangeEditPrjLoc()
  330. {
  331. // TODO: If this is a RICHEDIT control, the control will not
  332. // send this notification unless you override the CPropertyPage::OnInitDialog()
  333. // function and call CRichEditCtrl().SetEventMask()
  334. // with the ENM_CHANGE flag ORed into the mask.
  335. UpdateData();
  336. m_csoldPrjpath = m_csPrjpath ;
  337. }
  338. /***************************************************************************************
  339. void CNewProject::OnClickListTemplate(NMHDR* pNMHDR, LRESULT* pResult)
  340. ****************************************************************************************/
  341. void CNewProject::OnClickListTemplate(NMHDR* pNMHDR, LRESULT* pResult)
  342. {
  343. SetButton() ;
  344. *pResult = 0;
  345. }
  346. /***************************************************************************************
  347. void CNewProject::OnDblclkListTemplate(NMHDR* pNMHDR, LRESULT* pResult)
  348. ToDo ; Do nothing when no project name exist
  349. ****************************************************************************************/
  350. void CNewProject::OnDblclkListTemplate(NMHDR* pNMHDR, LRESULT* pResult)
  351. {
  352. POSITION pos = m_clcTemplate.GetFirstSelectedItemPosition();
  353. // template and project name has to be selected or exist
  354. if ( m_csPrjname.GetLength() != 0 && pos )
  355. m_pcps->PressButton(PSBTN_OK) ;
  356. else
  357. AfxMessageBox (_T("No Project name exist or template is not selected"), MB_ICONINFORMATION) ;
  358. *pResult = 0;
  359. }
  360. /***************************************************************************************
  361. void CNewProject::SetButton()
  362. ****************************************************************************************/
  363. void CNewProject::SetButton()
  364. {
  365. POSITION pos = m_clcTemplate.GetFirstSelectedItemPosition();
  366. // template and project name has to be selected or exist
  367. if ( m_csPrjname.GetLength() == 0 || !pos )
  368. m_pcps->GetDlgItem(IDOK)->EnableWindow(FALSE) ;
  369. else
  370. m_pcps->GetDlgItem(IDOK)->EnableWindow() ;
  371. }
  372. /***************************************************************************************
  373. void CNewProject::Serialize(CArchive& car)
  374. ****************************************************************************************/
  375. void CNewProject::Serialize(CArchive& car)
  376. {
  377. CPropertyPage::Serialize(car) ;
  378. if (car.IsStoring())
  379. {
  380. }
  381. else
  382. {
  383. }
  384. }
  385. /*****************************************************************************************
  386. void CNewProject::OnOK()
  387. ToDo : Creat poject directory as well as creat temp file for resource gpd file / get path
  388. of custom gpd file
  389. ******************************************************************************************/
  390. void CNewProject::OnOK()
  391. {
  392. // TODO: Add your specialized code here and/or call the base class
  393. UpdateData() ; // copy all edit value to its member data.
  394. POSITION pos = m_clcTemplate.GetFirstSelectedItemPosition();
  395. int iSelected = m_clcTemplate.GetNextSelectedItem(pos );
  396. if (iSelected < sizeof(TName)/sizeof(TName[0]) ) { // for using template from the resource
  397. CString cstmp = AfxGetApp()->m_pszHelpFilePath ;
  398. cstmp = cstmp.Left(cstmp.ReverseFind(_T('\\')) + 1 ) ;
  399. cstmp += _T("tmp.gpd") ;
  400. CFile cf(cstmp,CFile::modeCreate | CFile::modeWrite ) ;
  401. HRSRC hrsrc = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(TID[iSelected]),
  402. MAKEINTRESOURCE(IDR_NEWPROJECT));
  403. if (!hrsrc) {
  404. CString csError ;
  405. csError.LoadString(IDS_ResourceError) ;
  406. AfxMessageBox(csError,MB_ICONEXCLAMATION) ;
  407. return ;
  408. } ;
  409. HGLOBAL hgMap = LoadResource(AfxGetResourceHandle(), hrsrc);
  410. if (!hgMap)
  411. return ; // This should never happen!
  412. int nsize = SizeofResource(AfxGetResourceHandle(),hrsrc ) ;
  413. LPVOID lpv = LockResource(hgMap);
  414. cf.Write(lpv,nsize) ;
  415. m_csGPDpath = cf.GetFilePath() ;
  416. cf.Close() ;
  417. }
  418. else {
  419. m_csGPDpath = (LPCTSTR)m_cmstsTemplate[m_csaTlst[iSelected]] ;
  420. }
  421. // create directory
  422. SECURITY_ATTRIBUTES st;
  423. st.nLength = sizeof(SECURITY_ATTRIBUTES);
  424. st.lpSecurityDescriptor = NULL;
  425. st.bInheritHandle = FALSE ;
  426. if (!CreateDirectory(m_csPrjpath.GetBuffer(256),&st) ) {
  427. DWORD dwError = GetLastError() ;
  428. CString csmsg ;
  429. if ( dwError == ERROR_ALREADY_EXISTS)
  430. csmsg.LoadString(IDS_FileAlreadExist) ;
  431. else
  432. csmsg.LoadString(IDS_FileCreateDirectory) ;
  433. AfxMessageBox(csmsg) ;
  434. return ;
  435. }
  436. CString csTmp = m_clcTemplate.GetItemText(iSelected,0);
  437. //Check selected template if it required added file (PCL 6 need e more resource files)
  438. // if so, Call AddGpds() for creating these files
  439. if(!csTmp.Compare(_T("PCL 6") )&& !AddGpds(csTmp) ){
  440. CString csError ;
  441. csError.LoadString(IDS_ResourceError) ;
  442. AfxMessageBox(csError,MB_ICONEXCLAMATION) ;
  443. return ;
  444. }
  445. m_pcps->ShowWindow(SW_HIDE) ;
  446. CNewProjectWizard cntp (_T("New Project Wizard"), this ) ;
  447. if (cntp.DoModal() == IDCANCEL)
  448. m_pcps->ShowWindow(SW_RESTORE) ;
  449. else CPropertyPage::OnOK();
  450. }
  451. /***************************************************************************************
  452. bool CNewProject::AddGpds()
  453. Do : copy required gpd filss according to a selected template. for instance, PCL6 need pjl.gpd,
  454. p6disp.gpd, pclxl.gpd files.
  455. ****************************************************************************************/
  456. bool CNewProject::AddGpds(CString& csTemplate)
  457. {
  458. for (int i = 0 ; i < sizeof(AddID) / sizeof(AddID[0]) ; i ++ ) {
  459. CString cstmp = m_csPrjpath + _T('\\') + AddedGpd[i] ;
  460. CFile cf(cstmp,CFile::modeCreate | CFile::modeWrite ) ;
  461. HRSRC hrsrc = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(AddID[i]),
  462. MAKEINTRESOURCE(IDR_NEWPROJECT));
  463. if (!hrsrc) {
  464. CString csError ;
  465. csError.LoadString(IDS_ResourceError) ;
  466. AfxMessageBox(csError,MB_ICONEXCLAMATION) ;
  467. return false;
  468. } ;
  469. HGLOBAL hgMap = LoadResource(AfxGetResourceHandle(), hrsrc);
  470. if (!hgMap)
  471. return false ; // This should never happen!
  472. int nsize = SizeofResource(AfxGetResourceHandle(),hrsrc ) ;
  473. LPVOID lpv = LockResource(hgMap);
  474. cf.Write(lpv,nsize) ;
  475. cf.Close() ;
  476. }
  477. return true ;
  478. }
  479. /////////////////////////////////////////////////////////////////////////////
  480. // CNewPrjWResource dialog
  481. IMPLEMENT_DYNCREATE(CNewPrjWResource, CPropertyPage)
  482. CNewPrjWResource::CNewPrjWResource()
  483. : CPropertyPage(CNewPrjWResource::IDD)
  484. {
  485. //{{AFX_DATA_INIT(CNewPrjWResource)
  486. m_csUFMpath = _T("");
  487. m_csGTTpath = _T("");
  488. m_csGpdFileName = _T("");
  489. m_csModelName = _T("");
  490. m_csRCName = _T("");
  491. //}}AFX_DATA_INIT
  492. // m_csaUFMFiles.SetSize(10) ;
  493. // m_csaGTTFiles.SetSize(10) ;
  494. }
  495. void CNewPrjWResource::DoDataExchange(CDataExchange* pDX)
  496. {
  497. CPropertyPage::DoDataExchange(pDX);
  498. //{{AFX_DATA_MAP(CNewPrjWResource)
  499. DDX_Control(pDX, IDC_CHECK_FONTS, m_cbCheckFonts);
  500. DDX_Text(pDX, IDC_UFM_PATH, m_csUFMpath);
  501. DDX_Text(pDX, IDC_GTT_PATH, m_csGTTpath);
  502. DDX_Text(pDX, IDC_EDIT_GPD, m_csGpdFileName);
  503. DDX_Text(pDX, IDC_EDIT_MODEL, m_csModelName);
  504. DDX_Text(pDX, IDC_EDIT_RESOUREC, m_csRCName);
  505. //}}AFX_DATA_MAP
  506. }
  507. BEGIN_MESSAGE_MAP(CNewPrjWResource, CPropertyPage)
  508. //{{AFX_MSG_MAP(CNewPrjWResource)
  509. ON_BN_CLICKED(IDC_SerchUFM, OnSerchUFM)
  510. ON_BN_CLICKED(IDC_SearchGTT, OnSearchGTT)
  511. ON_BN_CLICKED(IDC_CHECK_FONTS, OnCheckFonts)
  512. ON_EN_CHANGE(IDC_EDIT_GPD, OnChangeEditGpd)
  513. ON_EN_CHANGE(IDC_EDIT_MODEL, OnChangeEditModel)
  514. ON_EN_CHANGE(IDC_EDIT_RESOUREC, OnChangeEditResourec)
  515. //}}AFX_MSG_MAP
  516. END_MESSAGE_MAP()
  517. /****************************************************************************************
  518. void CNewPrjWResource::OnSerchUFM()
  519. Search the ufm
  520. *****************************************************************************************/
  521. void CNewPrjWResource::OnSerchUFM()
  522. {
  523. UpdateData() ;
  524. CString csFilter( _T("*.ufm|*.ufm||") ) ;
  525. CFileDialog cfd(TRUE, _T(".ufm"), NULL,
  526. OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT, csFilter,
  527. this);
  528. cfd.m_ofn.lpstrFile = new char[8192];
  529. memset(cfd.m_ofn.lpstrFile,0,8192);
  530. cfd.m_ofn.nMaxFile = 8192;
  531. if (cfd.DoModal() != IDOK) {
  532. delete cfd.m_ofn.lpstrFile ;
  533. return;
  534. }
  535. // save the file path to member string array
  536. for (POSITION pos = cfd.GetStartPosition(); pos; ) {
  537. CString cspath = cfd.GetNextPathName(pos) ;
  538. m_csaUFMFiles.Add(cspath) ;
  539. }
  540. m_csUFMpath = m_csaUFMFiles[0] ;
  541. SetCurrentDirectory(m_csUFMpath.Left(m_csUFMpath.ReverseFind(_T('\\') ) ) ) ;
  542. UpdateData(FALSE) ;
  543. }
  544. /****************************************************************************************
  545. void CNewPrjWResource::OnSearchGTT()
  546. Search the gtt files
  547. *****************************************************************************************/
  548. void CNewPrjWResource::OnSearchGTT()
  549. {
  550. UpdateData() ; // in order to upgraded edit string value ;
  551. CString csFilter( _T("*.gtt|*.gtt||") ) ;
  552. CFileDialog cfd(TRUE, _T(".gtt"), NULL,
  553. OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT, csFilter,
  554. this);
  555. cfd.m_ofn.lpstrFile = new char[4096];
  556. memset(cfd.m_ofn.lpstrFile,0,4096);
  557. cfd.m_ofn.nMaxFile = 4096;
  558. if (cfd.DoModal() != IDOK) {
  559. delete cfd.m_ofn.lpstrFile ;
  560. return;
  561. }
  562. // save the file path to member string array
  563. for (POSITION pos = cfd.GetStartPosition(); pos; ) {
  564. m_csaGTTFiles.Add(cfd.GetNextPathName(pos)) ;
  565. }
  566. m_csGTTpath = m_csaGTTFiles[0] ;
  567. SetCurrentDirectory(m_csGTTpath.Left(m_csGTTpath.ReverseFind(_T('\\') ) ) ) ;
  568. UpdateData(FALSE) ;
  569. }
  570. /////////////////////////////////////////////////////////////////////////////
  571. // CNewPrjWResource message handlers
  572. /***************************************************************************************
  573. BOOL CNewPrjWResource::OnInitDialog()
  574. mainly disable controls
  575. *****************************************************************************************/
  576. BOOL CNewPrjWResource::OnInitDialog()
  577. {
  578. CPropertyPage::OnInitDialog();
  579. // uncheck the check box,
  580. m_cbCheckFonts.SetCheck(false) ;
  581. // disable Add Template Edit box
  582. GetDlgItem(IDC_UFM_PATH)->EnableWindow(FALSE) ;
  583. GetDlgItem(IDC_GTT_PATH)->EnableWindow(FALSE) ;
  584. GetDlgItem(IDC_SerchUFM)->EnableWindow(FALSE) ;
  585. GetDlgItem(IDC_SearchGTT)->EnableWindow(FALSE) ;
  586. return TRUE; // return TRUE unless you set the focus to a control
  587. // EXCEPTION: OCX Property Pages should return FALSE
  588. }
  589. /****************************************************************************************
  590. void CNewPrjWResource::OnCheckFonts()
  591. user want to include fonts inside new project, this routin does not mapping the RCID in
  592. a UFM to specifc GTT. user has to change these rcid value after project creation.
  593. *****************************************************************************************/
  594. void CNewPrjWResource::OnCheckFonts()
  595. {
  596. CEdit ceTName, ceTPath ;
  597. if ( m_cbCheckFonts.GetCheck() ) {// check the button
  598. GetDlgItem(IDC_UFM_PATH)->EnableWindow(TRUE) ;
  599. GetDlgItem(IDC_GTT_PATH)->EnableWindow(TRUE) ;
  600. GetDlgItem(IDC_SerchUFM)->EnableWindow(TRUE) ;
  601. GetDlgItem(IDC_SearchGTT)->EnableWindow(TRUE) ;
  602. }
  603. else {
  604. GetDlgItem(IDC_UFM_PATH)->EnableWindow(FALSE) ;
  605. GetDlgItem(IDC_GTT_PATH)->EnableWindow(FALSE) ;
  606. GetDlgItem(IDC_SerchUFM)->EnableWindow(FALSE) ;
  607. GetDlgItem(IDC_SearchGTT)->EnableWindow(FALSE) ;
  608. } ;
  609. }
  610. /****************************************************************************************
  611. BOOL CNewPrjWResource::OnSetActive()
  612. *****************************************************************************************/
  613. BOOL CNewPrjWResource::OnSetActive()
  614. {
  615. // change the NEXT to FINISH.
  616. ((CPropertySheet*)GetOwner())->SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH);
  617. ((CPropertySheet*)GetOwner())->SetWizardButtons(PSWIZB_DISABLEDFINISH);
  618. ((CPropertySheet*)GetOwner())->GetDlgItem(IDHELP)->ShowWindow(SW_HIDE) ;
  619. return CPropertyPage::OnSetActive();
  620. }
  621. /****************************************************************************************
  622. BOOL CNewPrjWResource::OnWizardFinish()
  623. this is workhouse. Creating directory and fils for project & build environment, and copies
  624. these files.
  625. *****************************************************************************************/
  626. BOOL CNewPrjWResource::OnWizardFinish()
  627. {
  628. UpdateData() ;
  629. m_pcnp = (CNewProject* )(( CNewProjectWizard* )GetParent() )->GetProjectPage() ;
  630. //// copied the resource file to project directory.////
  631. CString csPrjPath, csNewGPDPat, csUFMDir, csGTTDir,csGPDPath ;
  632. CStringArray csaNewUFMPath,csaNewGTTPath ;
  633. csPrjPath = m_pcnp->m_csPrjpath ;
  634. csGPDPath = m_pcnp->GetGPDpath() ;
  635. csUFMDir = csPrjPath + _T("\\UFM") ;
  636. csGTTDir = csPrjPath + _T("\\GTT") ;
  637. // create ufm, gtt directory
  638. SECURITY_ATTRIBUTES st;
  639. st.nLength = sizeof(SECURITY_ATTRIBUTES);
  640. st.lpSecurityDescriptor = NULL;
  641. st.bInheritHandle = FALSE ;
  642. if (!CreateDirectory(csUFMDir.GetBuffer(256),&st) ||
  643. !CreateDirectory(csGTTDir.GetBuffer(256),&st) ) {
  644. CString csmsg ;
  645. csmsg = _T("Fail to creat the resources (ufm, gtt) directory") ;
  646. AfxMessageBox(csmsg) ;
  647. return FALSE ;
  648. }
  649. // Copy Resource files to project class
  650. // UFM files
  651. for ( int i = 0 ; i< m_csaUFMFiles.GetSize() ; i++ ) {
  652. CString csname, cssrc, csdest;
  653. cssrc = m_csaUFMFiles[i] ;
  654. csname = cssrc.Mid(cssrc.ReverseFind(_T('\\')) + 1) ;
  655. csdest= csUFMDir + _T('\\') + csname ;
  656. if (!CopyFile(cssrc, csdest, TRUE)) {
  657. CString csmsg ;
  658. csmsg.Format(IDS_AddCopyFailed, cssrc,
  659. csdest.Left(csdest.GetLength() - 1)) ;
  660. csmsg += csdest ;
  661. AfxMessageBox(csmsg) ;
  662. return FALSE ;
  663. }
  664. m_csaUFMFiles.SetAt(i,csdest) ;
  665. }
  666. // GTT files
  667. for ( i = 0 ; i< m_csaGTTFiles.GetSize() ; i++ ) {
  668. CString csname, cssrc, csdest;
  669. cssrc = m_csaGTTFiles[i] ;
  670. csname = cssrc.Mid(cssrc.ReverseFind(_T('\\')) + 1) ;
  671. csdest= csGTTDir + _T('\\') + csname ;
  672. if (!CopyFile(cssrc, csdest, TRUE)) {
  673. CString csmsg ;
  674. csmsg.Format(IDS_AddCopyFailed, cssrc,
  675. csdest.Left(csdest.GetLength() - 1)) ;
  676. csmsg += csdest ;
  677. AfxMessageBox(csmsg) ;
  678. return FALSE ;
  679. }
  680. m_csaGTTFiles.SetAt(i,csdest) ;
  681. }
  682. // GPD files
  683. CString cssrc, csdest;
  684. cssrc = csGPDPath;
  685. if(!m_csGpdFileName.GetLength() )
  686. m_csGpdFileName = csPrjPath.Mid(csPrjPath.ReverseFind('\\') + 1 );
  687. csdest = csPrjPath + _T('\\') + m_csGpdFileName + _T(".gpd" ) ;
  688. if (!CopyFile(cssrc, csdest, TRUE)) {
  689. CString csmsg ;
  690. csmsg.Format(IDS_AddCopyFailed, cssrc,
  691. csdest.Left(csdest.GetLength() - 1)) ;
  692. csmsg += csdest ;
  693. AfxMessageBox(csmsg) ;
  694. return FALSE ;
  695. }
  696. csGPDPath.Delete(0,csGPDPath.GetLength());
  697. csGPDPath = csdest ;
  698. // Create RCID mapping from pcl5eres.txt and target GPD.
  699. CreateRCID(csdest) ;
  700. // Copy Stdnames.gpd ; use established module
  701. try {
  702. CString cssrc, csdest ;
  703. cssrc = ThisApp().GetAppPath() + _T("stdnames.gpd") ;
  704. csdest = csPrjPath + _T("\\") + _T("stdnames.gpd") ;
  705. CopyFile(cssrc, csdest, FALSE) ;
  706. }
  707. catch (CException *pce) {
  708. pce->ReportError() ;
  709. pce->Delete() ;
  710. // return FALSE ;
  711. }
  712. // Create the RC
  713. CString csRC,csSources, csMakefile ;
  714. if(!m_csRCName.GetLength() )
  715. m_csRCName = csPrjPath.Mid(csPrjPath.ReverseFind('\\') + 1 );
  716. csRC = csPrjPath + _T('\\') + m_csRCName + _T(".rc" ) ;
  717. CFile cfRC(csRC,CFile::modeCreate | CFile::modeWrite ) ;
  718. cfRC.Close() ;
  719. // Create the SOURCES files
  720. csSources = csPrjPath + _T("\\sources") ;
  721. CFile cf(csSources,CFile::modeCreate | CFile::modeWrite ) ;
  722. HRSRC hrsrc = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(150),
  723. MAKEINTRESOURCE(IDR_NEWSOURCES));
  724. if (!hrsrc) {
  725. AfxMessageBox(_T("Fail to create new sources due to insufficient resource, you have to \
  726. make sources file for the build "), MB_ICONEXCLAMATION ) ;
  727. } ;
  728. HGLOBAL hgMap = LoadResource(AfxGetResourceHandle(), hrsrc);
  729. if (!hgMap)
  730. return FALSE; // This should never happen!
  731. int nsize = SizeofResource(AfxGetResourceHandle(),hrsrc ) ;
  732. LPVOID lpv = LockResource(hgMap);
  733. cf.Write(lpv,nsize) ;
  734. CString cssource = cf.GetFilePath() ;
  735. cf.Close() ;
  736. //We need to copy more gpd file if user select PCL6 template mmm..
  737. //Get file from the resource 3 files ( pjl.gpd, p6disp.gpd, pclxl.gpd )
  738. //Update the SOURCES file
  739. CModelData cmd;
  740. cmd.SetKeywordValue(cssource,_T("TARGETNAME"),m_csRCName,true) ;
  741. cmd.SetKeywordValue(cssource,_T("SOURCES"),m_csRCName + _T(".rc"),true );
  742. cmd.SetKeywordValue(cssource,_T("MISCFILES"), m_csGpdFileName + _T(".GPD"),true ) ;
  743. // Create the MAKEFILE.
  744. csMakefile = csPrjPath + _T("\\makefile") ;
  745. CFile cfMakefile(csMakefile,CFile::modeCreate | CFile::modeWrite ) ;
  746. // should fill the contents of the makefile
  747. CString cstemp(_T("!INCLUDE $(NTMAKEENV)\\makefile.def") );
  748. cfMakefile.Write(cstemp,cstemp.GetLength() ) ;
  749. cfMakefile.Close() ;
  750. // Create the DEF file
  751. CString csDeffile = csPrjPath + _T("\\") + m_csRCName + _T(".def") ;
  752. CFile cfDeffile(csDeffile,CFile::modeCreate | CFile::modeWrite ) ;
  753. cstemp.Empty() ;
  754. cstemp = _T("LIBRARY ") + m_csRCName ;
  755. cfDeffile.Write(cstemp,cstemp.GetLength() ) ;
  756. cfDeffile.Close() ;
  757. // Call the Frame of the project workspace
  758. CMultiDocTemplate* pcmdtWorkspace = ThisApp().WorkspaceTemplate() ;
  759. CDocument* pcdWS = pcmdtWorkspace->CreateNewDocument();
  760. CProjectRecord *ppr = DYNAMIC_DOWNCAST(CProjectRecord,pcdWS ) ;
  761. ppr->CreateFromNew(m_csaUFMFiles, m_csaGTTFiles,csGPDPath,m_csModelName,m_csRCName,m_csaRcid) ;
  762. pcmdtWorkspace-> SetDefaultTitle(pcdWS);
  763. CFrameWnd* pcfw = pcmdtWorkspace -> CreateNewFrame(pcdWS, NULL);
  764. if (!pcfw)
  765. return FALSE;
  766. pcmdtWorkspace -> InitialUpdateFrame(pcfw, pcdWS);
  767. // SetCurrentDirectory(csPrjPath ) ;
  768. return CPropertyPage::OnWizardFinish();
  769. }
  770. /****************************************************************************************
  771. LRESULT CNewPrjWResource::OnWizardBack()
  772. this lead close all windows inlcuding parent window, because this dialog box created under
  773. OnOK of parent dialog box. need to be updated.
  774. *****************************************************************************************/
  775. LRESULT CNewPrjWResource::OnWizardBack()
  776. {
  777. return ((CPropertySheet*)GetParent())->PressButton(PSBTN_CANCEL ) ;
  778. // return CPropertyPage::OnWizardBack();
  779. }
  780. /****************************************************************************************
  781. void CNewPrjWResource::OnChangeEditGpd()
  782. *****************************************************************************************/
  783. void CNewPrjWResource::OnChangeEditGpd()
  784. {
  785. // TODO: If this is a RICHEDIT control, the control will not
  786. // send this notification unless you override the CPropertyPage::OnInitDialog()
  787. // function and call CRichEditCtrl().SetEventMask()
  788. // with the ENM_CHANGE flag ORed into the mask.
  789. UpdateData() ;
  790. if(m_csGpdFileName.GetLength() && m_csModelName.GetLength() && m_csRCName.GetLength() )
  791. ((CPropertySheet*)GetOwner())->SetWizardButtons(PSWIZB_FINISH);
  792. else
  793. ((CPropertySheet*)GetOwner())->SetWizardButtons(PSWIZB_DISABLEDFINISH);
  794. }
  795. /****************************************************************************************
  796. void CNewPrjWResource::OnChangeEditModel()
  797. all these three value(model name, rc name, gdp file name ) should exist for creating project
  798. *****************************************************************************************/
  799. void CNewPrjWResource::OnChangeEditModel()
  800. {
  801. // TODO: If this is a RICHEDIT control, the control will not
  802. // send this notification unless you override the CPropertyPage::OnInitDialog()
  803. // function and call CRichEditCtrl().SetEventMask()
  804. // with the ENM_CHANGE flag ORed into the mask.
  805. UpdateData() ;
  806. if(m_csGpdFileName.GetLength() && m_csModelName.GetLength() && m_csRCName.GetLength() )
  807. ((CPropertySheet*)GetOwner())->SetWizardButtons(PSWIZB_FINISH);
  808. else
  809. ((CPropertySheet*)GetOwner())->SetWizardButtons(PSWIZB_DISABLEDFINISH);
  810. }
  811. /****************************************************************************************
  812. void CNewPrjWResource::OnChangeEditResourec()
  813. *****************************************************************************************/
  814. void CNewPrjWResource::OnChangeEditResourec()
  815. {
  816. // TODO: If this is a RICHEDIT control, the control will not
  817. // send this notification unless you override the CPropertyPage::OnInitDialog()
  818. // function and call CRichEditCtrl().SetEventMask()
  819. // with the ENM_CHANGE flag ORed into the mask.
  820. UpdateData() ;
  821. if(m_csGpdFileName.GetLength() && m_csModelName.GetLength() && m_csRCName.GetLength() )
  822. ((CPropertySheet*)GetOwner())->SetWizardButtons(PSWIZB_FINISH);
  823. else
  824. ((CPropertySheet*)GetOwner())->SetWizardButtons(PSWIZB_DISABLEDFINISH);
  825. }
  826. /*****************************************************************************************
  827. void CNewPrjWResource::CreateRCID(CString csGPD)
  828. if (pcl.txt)
  829. read the pcl.txt
  830. else
  831. read from the resource and create pcl.txt under root
  832. compare (pcl.txt value and rc value in the gpd)
  833. creating list of existing string and value
  834. ******************************************************************************************/
  835. void CNewPrjWResource::CreateRCID(CString csGPD)
  836. {
  837. // check pcl.txt: 1st, mdt help directory 2nd. load resource file
  838. CString cstable = AfxGetApp()->m_pszHelpFilePath ;
  839. cstable = cstable.Left(cstable.ReverseFind(_T('\\')) + 1 ) ;
  840. cstable += _T("pcl.txt") ;
  841. CFileFind cff ;
  842. if (! cff.FindFile(cstable) ) {
  843. // load from the resource files
  844. CFile cf(cstable,CFile::modeCreate | CFile::modeWrite ) ;
  845. HRSRC hrsrc = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(200),
  846. MAKEINTRESOURCE(IDR_STRINGTABLE));
  847. if (!hrsrc) {
  848. AfxMessageBox(_T("Fail to create new project due to insufficient resource"), MB_ICONEXCLAMATION ) ;
  849. return ;
  850. } ;
  851. HGLOBAL hgMap = LoadResource(AfxGetResourceHandle(), hrsrc);
  852. if (!hgMap)
  853. return ; // This should never happen!
  854. int nsize = SizeofResource(AfxGetResourceHandle(),hrsrc ) ;
  855. LPVOID lpv = LockResource(hgMap);
  856. cf.Write(lpv,nsize) ;
  857. cf.Close() ;
  858. }
  859. // Get Every rcNameID value from the GPD
  860. CStringArray csaData;
  861. if(!LoadFile(csGPD,csaData)){ // call global function in minidev.h(which is include for this fucntion)
  862. CString csErr;
  863. csErr.Format(IDS_InvalidFilename, csGPD);
  864. AfxMessageBox(csErr,MB_OK);
  865. return ;
  866. }
  867. CDWordArray cdwRcid ;
  868. CString csline;
  869. CString csKeyword = _T("rcNameID:") ;
  870. int offset ;
  871. for (int i = 0 ; i < csaData.GetSize() ; i ++ ) {
  872. csline = csaData[i];
  873. if(-1 ==(offset=csline.Find(csKeyword)) )
  874. continue;
  875. else
  876. {
  877. csline = csline.Mid(offset+csKeyword.GetLength());
  878. int ircid = atoi(csline) ;
  879. if (ircid)
  880. cdwRcid.Add(ircid) ;
  881. }
  882. }
  883. // Search the pcl.txt for the rcNameID
  884. csaData.RemoveAll() ;
  885. if(!LoadFile(cstable,csaData)){
  886. CString csErr;
  887. csErr.Format(IDS_InvalidFilename, csGPD);
  888. AfxMessageBox(csErr,MB_OK);
  889. return ;
  890. }
  891. // save rcid and string to string table array
  892. CStringTable cstrcid ;
  893. for (i = 0 ; i < csaData.GetSize() ;i ++ ) {
  894. csline = csaData[i] ;
  895. WORD wKey = (WORD) atoi(csline);
  896. if (!wKey)
  897. continue ; // 0 is not a valid resource number...
  898. csline = csline.Mid(csline.Find("\""));
  899. csline = csline.Mid(1, -2 + csline.GetLength());
  900. cstrcid.Map(wKey, csline);
  901. }
  902. // save slelected line from pcl.txt after matching pcl.txt data and seleted gpd rcid
  903. CString cstmp ;
  904. for ( i = 0 ; i < cdwRcid.GetSize() ; i ++ ) {
  905. WORD wKey = (WORD) cdwRcid[i] ;
  906. csline = cstrcid[wKey] ;
  907. cstmp.Format("%d",wKey) ;
  908. csline = cstmp + _T("\"") + csline ;
  909. m_csaRcid.Add(csline ) ;
  910. }
  911. }
  912. /////////////////////////////////////////////////////////////////////////////
  913. // CNewProjectWizard
  914. IMPLEMENT_DYNAMIC(CNewProjectWizard, CPropertySheet)
  915. CNewProjectWizard::CNewProjectWizard(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
  916. :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
  917. {
  918. }
  919. CNewProjectWizard::CNewProjectWizard(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
  920. :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
  921. {
  922. AddPage(&m_cpwr) ;
  923. m_pParent = pParentWnd ;
  924. SetWizardMode() ;
  925. }
  926. CNewProjectWizard::~CNewProjectWizard()
  927. {
  928. }
  929. BEGIN_MESSAGE_MAP(CNewProjectWizard, CPropertySheet)
  930. //{{AFX_MSG_MAP(CNewProjectWizard)
  931. // NOTE - the ClassWizard will add and remove mapping macros here.
  932. //}}AFX_MSG_MAP
  933. END_MESSAGE_MAP()
  934. /////////////////////////////////////////////////////////////////////////////
  935. // CNewProjectWizard message handlers
  936. /*************************************************************************************
  937. CPropertyPage* CNewProjectWizard::GetProjectPage()
  938. this is just propertysheet for project wizard, Currently project wizard contain only one
  939. propertypage, but it can be expand to more propertypage so medium properysheet is required
  940. for the future use rather that just us one dialog box
  941. **************************************************************************************/
  942. CPropertyPage* CNewProjectWizard::GetProjectPage()
  943. {
  944. CNewComponent* pcnc = (CNewComponent* ) GetParent();
  945. return (CPropertyPage*)pcnc->GetProjectPage() ; ;
  946. }