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.

863 lines
26 KiB

  1. /******************************************************************************
  2. Source File: Project View.CPP
  3. This implements the view class for project level information.
  4. Copyright (c) 1997 by Microsoft Corporation. All Rights Reserved.
  5. A Pretty Penny Enterprises Production.
  6. Change History:
  7. 02-03-1997 Bob_Kjelgaard@Prodigy.Net Created it
  8. ******************************************************************************/
  9. #include "StdAfx.h"
  10. #include <gpdparse.h>
  11. #include "MiniDev.H"
  12. #include "Resource.H"
  13. #include "comctrls.h"
  14. #include "ProjView.H"
  15. #include "INFWizrd.H"
  16. #include "Gpdfile.H"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CProjectView
  24. IMPLEMENT_DYNCREATE(CProjectView, CFormView)
  25. BEGIN_MESSAGE_MAP(CProjectView, CFormView)
  26. //{{AFX_MSG_MAP(CProjectView)
  27. ON_NOTIFY(TVN_BEGINLABELEDIT, IDC_DriverView, OnBeginlabeleditDriverView)
  28. ON_NOTIFY(TVN_ENDLABELEDIT, IDC_DriverView, OnEndLabelEdit)
  29. ON_WM_CONTEXTMENU()
  30. ON_NOTIFY(NM_DBLCLK, IDC_DriverView, OnDblclkDriverView)
  31. ON_COMMAND(ID_FILE_PARSE, OnFileParse)
  32. ON_NOTIFY(TVN_KEYDOWN, IDC_DriverView, OnKeydownDriverView)
  33. ON_WM_SIZE()
  34. ON_COMMAND(ID_FILE_CheckWS, OnCheckWorkspace)
  35. ON_COMMAND(ID_FILE_INF, OnFileInf)
  36. //}}AFX_MSG_MAP
  37. // Standard printing commands
  38. // ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint) //RAID 135232 no printing in project view
  39. ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
  40. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
  41. // Commands we pop up from context menus
  42. ON_COMMAND(ID_ExpandBranch, OnExpandBranch)
  43. ON_COMMAND(ID_CollapseBranch, OnCollapseBranch)
  44. ON_COMMAND(ID_RenameItem, OnRenameItem)
  45. ON_COMMAND(ID_OpenItem, OnOpenItem)
  46. //ON_COMMAND(ID_GenerateOne, OnGenerateItem)
  47. ON_COMMAND(IDOK, OnOpenItem) // We'll open an item if ENTER is hit
  48. ON_COMMAND(ID_Import, OnImport)
  49. ON_COMMAND(ID_DeleteItem, OnDeleteItem)
  50. ON_COMMAND(ID_CopyItem, OnCopyItem)
  51. ON_COMMAND(ID_ChangeID, OnChangeID)
  52. ON_COMMAND(ID_CheckWS, OnCheckWorkspace)
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CProjectView construction/destruction
  56. CProjectView::CProjectView() : CFormView(CProjectView::IDD) {
  57. //{{AFX_DATA_INIT(CProjectView)
  58. //}}AFX_DATA_INIT
  59. // Resizing is not ok, yet
  60. bResizingOK = false ;
  61. }
  62. CProjectView::~CProjectView()
  63. {
  64. }
  65. void CProjectView::DoDataExchange(CDataExchange* pDX) {
  66. CFormView::DoDataExchange(pDX);
  67. //{{AFX_DATA_MAP(CProjectView)
  68. DDX_Control(pDX, IDC_DriverView, m_ctcDriver);
  69. //}}AFX_DATA_MAP
  70. }
  71. BOOL CProjectView::PreCreateWindow(CREATESTRUCT& cs) {
  72. // TODO: Modify the Window class or styles here by modifying
  73. // the CREATESTRUCT cs
  74. cs.lpszClass = _T("Workspace") ; // raid 104822
  75. return CScrollView::PreCreateWindow(cs);
  76. }
  77. /////////////////////////////////////////////////////////////////////////////
  78. // CProjectView drawing
  79. void CProjectView::OnInitialUpdate() {
  80. CFormView::OnInitialUpdate();
  81. ResizeParentToFit(FALSE);
  82. //GetDocument() -> VerUpdateFilePaths();
  83. GetDocument() -> InitUI(&m_ctcDriver);
  84. GetParentFrame() -> ShowWindow(SW_SHOW);
  85. GetDocument() -> GPDConversionCheck();
  86. // Get the current dimensions of the workspace view window and the other
  87. // control(s) that can be resized. Then set the flag that says that
  88. // resizing is ok now.
  89. WINDOWPLACEMENT wp ;
  90. wp.length = sizeof(WINDOWPLACEMENT) ;
  91. GetWindowPlacement(&wp) ;
  92. crWSVOrgDims = wp.rcNormalPosition ;
  93. crWSVCurDims = crWSVOrgDims ;
  94. m_ctcDriver.GetWindowPlacement(&wp) ;
  95. crTreeOrgDims = wp.rcNormalPosition ;
  96. crTreeCurDims = crTreeOrgDims ;
  97. HWND hlblhandle ;
  98. GetDlgItem(IDC_ProjectLabel, &hlblhandle) ;
  99. ::GetWindowPlacement(hlblhandle, &wp) ;
  100. crLblOrgDims = wp.rcNormalPosition ;
  101. crLblCurDims = crLblOrgDims ;
  102. bResizingOK = true ;
  103. }
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CProjectView printing
  106. BOOL CProjectView::OnPreparePrinting(CPrintInfo* pInfo) {
  107. // default preparation
  108. return DoPreparePrinting(pInfo);
  109. }
  110. void CProjectView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) {
  111. // TODO: add extra initialization before printing
  112. }
  113. void CProjectView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) {
  114. // TODO: add cleanup after printing
  115. }
  116. /////////////////////////////////////////////////////////////////////////////
  117. // CProjectView diagnostics
  118. #ifdef _DEBUG
  119. void CProjectView::AssertValid() const {
  120. CScrollView::AssertValid();
  121. }
  122. void CProjectView::Dump(CDumpContext& dc) const {
  123. CScrollView::Dump(dc);
  124. }
  125. CProjectRecord* CProjectView::GetDocument() {// non-debug version is inline
  126. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CProjectRecord)));
  127. return (CProjectRecord*)m_pDocument;
  128. }
  129. #endif //_DEBUG
  130. /////////////////////////////////////////////////////////////////////////////
  131. // CProjectView message handlers
  132. void CProjectView::OnBeginlabeleditDriverView(NMHDR* pnmh, LRESULT* plr) {
  133. TV_DISPINFO* ptvdi = (TV_DISPINFO*) pnmh;
  134. *plr = !((CBasicNode *) ptvdi -> item.lParam) -> CanEdit();
  135. }
  136. /******************************************************************************
  137. CProjectView::OnEndLabelEdit
  138. Called when a label in the view has been edited- the user has either
  139. canceled (new text in item will be empty), or changed the text. We pass the
  140. whole information on to the CBasicNode which handles this object.
  141. ******************************************************************************/
  142. void CProjectView::OnEndLabelEdit(NMHDR* pnmh, LRESULT* plr) {
  143. TV_DISPINFO* ptvdi = (TV_DISPINFO*) pnmh;
  144. *plr = ((CBasicNode *) ptvdi -> item.lParam) -> Rename(ptvdi ->
  145. item.pszText);
  146. //raid 19658
  147. CString csfile = ptvdi->item.pszText;
  148. int offset;
  149. if(-1 != (offset=csfile.ReverseFind(_T('\\')) ) ) {
  150. CModelData cmd;
  151. CString csValue = csfile.Mid(offset+1);
  152. // csValue.MakeUpper();
  153. csValue += _T(".GPD");
  154. csfile += _T(".gpd");
  155. cmd.SetKeywordValue(csfile,_T("*GPDFileName"),csValue);
  156. }
  157. }
  158. /******************************************************************************
  159. CProjectView::OnContextMenu
  160. This is called when the user right-clicks the mouse. We determine if the
  161. mouse is within an item in the tree view. If it is, then we pass it on to
  162. the CBasicNode-derived object which handles that item. That object is then
  163. responsible for displaying the proper context menu.
  164. ******************************************************************************/
  165. void CProjectView::OnContextMenu(CWnd* pcw, CPoint cp) {
  166. if (pcw != &m_ctcDriver)
  167. return;
  168. CPoint cpThis(cp);
  169. m_ctcDriver.ScreenToClient(&cpThis);
  170. // If the mouse is inside the area of any item, display its context menu
  171. UINT ufItem;
  172. HTREEITEM hti = m_ctcDriver.HitTest(cpThis, &ufItem);
  173. if (!hti || !(ufItem & (TVHT_ONITEM | TVHT_ONITEMBUTTON)))
  174. return;
  175. // Some operations require we know which item, so we're going to
  176. // select the given item. If this is really a problem, we can change
  177. // it later (cache it in a member).
  178. m_ctcDriver.SelectItem(hti);
  179. ((CBasicNode *) m_ctcDriver.GetItemData(hti)) -> ContextMenu(this, cp);
  180. }
  181. /******************************************************************************
  182. CProjectView::OnExpandBranch
  183. This is called when the user selects an expand item from a context menu. In
  184. this case, we don't need to pass this through the CBasicNode- we just expand
  185. it using the normal common control methods (actually using an MFC method,
  186. since this promises greater future portability).
  187. ******************************************************************************/
  188. void CProjectView::OnExpandBranch() {
  189. HTREEITEM htiSelected = m_ctcDriver.GetSelectedItem();
  190. if (!htiSelected)
  191. return;
  192. m_ctcDriver.Expand(htiSelected, TVE_EXPAND);
  193. }
  194. /******************************************************************************
  195. CProjectView::OnCollapseBranch
  196. In this case, the user has selected the Collapse item from a context menu.
  197. We collapse the branch at the selected tree view item.
  198. ******************************************************************************/
  199. void CProjectView::OnCollapseBranch() {
  200. HTREEITEM htiSelected = m_ctcDriver.GetSelectedItem();
  201. if (!htiSelected)
  202. return;
  203. m_ctcDriver.Expand(htiSelected, TVE_COLLAPSE);
  204. }
  205. /******************************************************************************
  206. CProjectView::OnRenameItem
  207. This handles a user selecting a Rename item. This results in us ordering the
  208. view to begin label editing of the selected item. The interactions regarding
  209. label editing are routed to the underlying CBasicNode object via
  210. OnBeginLabelEdit and OnEndLabelEdit.
  211. ******************************************************************************/
  212. void CProjectView::OnRenameItem() {
  213. HTREEITEM htiSelected = m_ctcDriver.GetSelectedItem();
  214. if (!htiSelected)
  215. return;
  216. m_ctcDriver.EditLabel(htiSelected);
  217. }
  218. /******************************************************************************
  219. CProjectView::OnOpenItem
  220. This method is invoked when the user wishes to edit an item in the tree.
  221. This is always routed through the underlying CBasicNode-derived item. Some
  222. items can't be edited, and will ignore this (in fact, this is the base class
  223. behavior).
  224. ******************************************************************************/
  225. void CProjectView::OnOpenItem() {
  226. HTREEITEM htiSelected = m_ctcDriver.GetSelectedItem();
  227. if (!htiSelected)
  228. return;
  229. // raid 8350
  230. CWnd *cwd = FromHandle(m_hWnd);
  231. (cwd->GetParent()) -> ShowWindow(SW_SHOWNORMAL );
  232. ((CBasicNode *) m_ctcDriver.GetItemData(htiSelected)) -> Edit();
  233. }
  234. // Generate an image of the selected item (usable for building)
  235. /* No longer supported
  236. void CProjectView::OnGenerateItem() {
  237. HTREEITEM htiSelected = m_ctcDriver.GetSelectedItem();
  238. if (!htiSelected)
  239. return;
  240. //((CProjectNode *) m_ctcDriver.GetItemData(htiSelected)) -> Generate();
  241. }
  242. */
  243. /******************************************************************************
  244. CProjectView::OnDblClkDriverView
  245. This is called when the user double-clicks anywhere in the tree view. We
  246. route it through the Open message handler, as this will always be the desired
  247. action.
  248. ******************************************************************************/
  249. void CProjectView::OnDblclkDriverView(NMHDR* pNMHDR, LRESULT* pResult) {
  250. OnOpenItem();
  251. }
  252. /******************************************************************************
  253. CProjectView::OnFileParse
  254. This method invokes the parser on each of the GPD files in the project.
  255. ******************************************************************************/
  256. void CProjectView::OnFileParse() {
  257. {
  258. CWaitCursor cwc; // This could take a while...
  259. for (unsigned u = 0; u < GetDocument() -> ModelCount(); u++) {
  260. GetDocument() -> Model(u).Parse(0);
  261. GetDocument() -> Model(u).UpdateEditor();
  262. }
  263. }
  264. GetDocument() -> GPDConversionCheck(TRUE);
  265. }
  266. /******************************************************************************
  267. CProjectView::OnKeydownDriverView
  268. This handles various keystrokes we want handled over and above what the
  269. default handling by the control supplies.
  270. ******************************************************************************/
  271. void CProjectView::OnKeydownDriverView(NMHDR* pnmh, LRESULT* plr) {
  272. TV_KEYDOWN* ptvkd = (TV_KEYDOWN*)pnmh;
  273. HTREEITEM htiSelected = m_ctcDriver.GetSelectedItem();
  274. *plr = 0;
  275. if (!htiSelected)
  276. return;
  277. CRect crThis;
  278. m_ctcDriver.GetItemRect(htiSelected, crThis, FALSE);
  279. CBasicNode& cbn = *(CBasicNode *) m_ctcDriver.GetItemData(htiSelected);
  280. switch (ptvkd -> wVKey) {
  281. case VK_F10:
  282. // Create a context menu for this item.
  283. m_ctcDriver.ClientToScreen(crThis);
  284. cbn.ContextMenu(this, crThis.CenterPoint());
  285. return;
  286. case VK_DELETE:
  287. // If the item is successfully deleted, remove it from the
  288. // view
  289. OnDeleteItem(); //add (raid 7227)
  290. // cbn.Delete(); //delete(raid 7227)
  291. return;
  292. //RAID 7227 add hot key
  293. //Open F2, Copy F3, Rename, Delete DELETE Key,
  294. case VK_F2:
  295. OnOpenItem();
  296. return;
  297. case VK_F3:
  298. OnCopyItem();
  299. return;
  300. case VK_F4:
  301. OnRenameItem();
  302. return;
  303. }
  304. }
  305. /******************************************************************************
  306. CProjectView::OnImport
  307. This method is invoked when the user selects an "Import" item on a context
  308. menu. How this is handled is entirely the responsibility of the underlying
  309. CBasicNode-derived item, so the request gets routed there by this code.
  310. ******************************************************************************/
  311. void CProjectView::OnImport() {
  312. HTREEITEM htiSelected = m_ctcDriver.GetSelectedItem();
  313. if (!htiSelected)
  314. return;
  315. ((CBasicNode *) m_ctcDriver.GetItemData(htiSelected)) -> Import();
  316. }
  317. /******************************************************************************
  318. CProjectView::OnDeleteItem
  319. For item deletion via context menu. The delete key is handled in
  320. OnKeydownDriverView. Once again, the underlying object handles what happens.
  321. BUT, before that happens, this routine handles the common UI because of
  322. oddities with working with the DLLs.
  323. ******************************************************************************/
  324. void CProjectView::OnDeleteItem()
  325. {
  326. HTREEITEM htiSelected = m_ctcDriver.GetSelectedItem();
  327. if (!htiSelected)
  328. return;
  329. // The selected item should be a pointer to a project node+. Get a pointer
  330. // to the node and verify its type. Return if the type is incorrect.
  331. CProjectNode* pcpn = (CProjectNode*) m_ctcDriver.GetItemData(htiSelected) ;
  332. if (!pcpn->IsKindOf(RUNTIME_CLASS(CProjectNode)))
  333. return ;
  334. // Init and prompt for the new RC ID. Return if the user cancels.
  335. CDeleteQuery cdq;
  336. CString cstmp(pcpn->FileExt()) ;
  337. cstmp = cstmp.Mid(1) ;
  338. cdq.Init(cstmp, pcpn->Name()) ;
  339. if (cdq.DoModal() != IDYES)
  340. return ;
  341. // Walk back up the hierarchy to find the owning Fixed node, and
  342. // remove us from the array for that node- since that member is a
  343. // reference to the array, all will work as it should.
  344. CFixedNode& cfn = * (CFixedNode *) m_ctcDriver.GetItemData(
  345. m_ctcDriver.GetParentItem(pcpn->Handle())) ;
  346. ASSERT(cfn.IsKindOf(RUNTIME_CLASS(CFixedNode))) ;
  347. cfn.Zap(pcpn, cdq.KillFile());
  348. // WARNING: the object pointed to by this has been deleted do NOTHING
  349. // from this point on that could cause the pointer to be dereferenced!
  350. }
  351. /******************************************************************************
  352. CProjectView::OnCopyItem
  353. For item copy via context menu. Once again, the underlying object handles
  354. what happens. BUT, before that happens, this routine handles the common UI
  355. because of oddities with working with the DLLs.
  356. ******************************************************************************/
  357. void CProjectView::OnCopyItem()
  358. {
  359. // Just return if nothing is selected.
  360. HTREEITEM htiSelected = m_ctcDriver.GetSelectedItem();
  361. if (!htiSelected)
  362. return ;
  363. // The selected item should be a pointer to a project node+. Get a pointer
  364. // to the node and verify its type. Return if the type is incorrect.
  365. CProjectNode* pcpn = (CProjectNode*) m_ctcDriver.GetItemData(htiSelected) ;
  366. if (!pcpn->IsKindOf(RUNTIME_CLASS(CProjectNode)))
  367. return ;
  368. // Prompt for the new file name. Return if the user cancels.
  369. CCopyItem cci ;
  370. cci.Init(pcpn->FileTitleExt()) ;
  371. if (cci.DoModal() == IDCANCEL)
  372. return ;
  373. // Walk back up the hierarchy to find this project node's owning Fixed node.
  374. CFixedNode& cfn = * (CFixedNode *) m_ctcDriver.GetItemData(
  375. m_ctcDriver.GetParentItem(pcpn->Handle())) ;
  376. ASSERT(cfn.IsKindOf(RUNTIME_CLASS(CFixedNode)));
  377. // Call the fixed node to make the copy of its child.
  378. cfn.Copy(pcpn, cci.m_csCopyName) ;
  379. }
  380. /******************************************************************************
  381. CProjectView::OnChangeID
  382. Called to change a resource ID via context menu. Once again, the underlying
  383. object handles what happens. BUT, before that happens, this routine handles
  384. the common UI because of oddities with working with the DLLs.
  385. ******************************************************************************/
  386. void CProjectView::OnChangeID()
  387. {
  388. // Just return if nothing is selected.
  389. HTREEITEM htiSelected = m_ctcDriver.GetSelectedItem();
  390. if (!htiSelected)
  391. return ;
  392. // The selected item should be a pointer to a RCID node. Get a pointer
  393. // to the node and verify its type. Return if the type is incorrect.
  394. CRCIDNode* prcidn = (CRCIDNode*) m_ctcDriver.GetItemData(htiSelected) ;
  395. if (!prcidn->IsKindOf(RUNTIME_CLASS(CRCIDNode)))
  396. return ;
  397. // Walk back up the hierarchy to find this RCID node's owning project node.
  398. CProjectNode& cpn = * (CProjectNode *) m_ctcDriver.GetItemData(
  399. m_ctcDriver.GetParentItem(prcidn->Handle())) ;
  400. ASSERT(cpn.IsKindOf(RUNTIME_CLASS(CProjectNode)));
  401. // Init and prompt for the new RC ID. Return if the user cancels.
  402. CChangeID ccid ;
  403. CString cstmp(cpn.FileExt()) ;
  404. cstmp = cstmp.Mid(1) ;
  405. ccid.Init(cstmp, cpn.Name(), prcidn->nGetRCID()) ;
  406. if (ccid.DoModal() == IDCANCEL)
  407. return ;
  408. // Call a project node function to finish the work.
  409. cpn.ChangeID(prcidn, ccid.m_nNewResID, cstmp) ;
  410. }
  411. /******************************************************************************
  412. CProjectView::OnCheckWorkspace
  413. Called to check a workspace for completeness and tidiness.
  414. ******************************************************************************/
  415. void CProjectView::OnCheckWorkspace()
  416. {
  417. // Save the current directory
  418. CString cscurdir ;
  419. ::GetCurrentDirectory(512, cscurdir.GetBuffer(512)) ;
  420. cscurdir.ReleaseBuffer() ;
  421. // Change the current directory to the directory containing the GPDs and
  422. // then check the workspace.
  423. SetCurrentDirectory(((CProjectRecord*) GetDocument())->GetW2000Path()) ;
  424. GetDocument()->WorkspaceChecker(false) ;
  425. // Reset the original directory
  426. SetCurrentDirectory(cscurdir) ;
  427. }
  428. /******************************************************************************
  429. CProjectView::OnSize
  430. Resize the label and tree control in the workspace view when the view is
  431. resized.
  432. ******************************************************************************/
  433. void CProjectView::OnSize(UINT ntype, int cx, int cy)
  434. {
  435. // First, call this routine for the base class
  436. CFormView::OnSize(ntype, cx, cy) ;
  437. // Do nothing else if the other data needed for resizing is uninitialized.
  438. // Also ignore all WM_SIZE messages except those with types of either
  439. // SIZE_MAXIMIZED or SIZE_RESTORED.
  440. if (!bResizingOK || (ntype != SIZE_MAXIMIZED && ntype != SIZE_RESTORED))
  441. return ;
  442. // Determine how much the window's dimensions have changed
  443. int ndx = cx - crWSVCurDims.Width() ;
  444. int ndy = cy - crWSVCurDims.Height() ;
  445. crWSVCurDims.right += ndx ;
  446. crWSVCurDims.bottom += ndy ;
  447. // Update the tree control's dimensions based on how much the window has
  448. // changed, make sure the control's minimums have not been exceeded, and
  449. // then change the size of the tree control.
  450. crTreeCurDims.right += ndx ;
  451. crTreeCurDims.bottom += ndy ;
  452. if (crTreeOrgDims.Width() > crTreeCurDims.Width()
  453. || crWSVOrgDims.Width() >= crWSVCurDims.Width())
  454. crTreeCurDims.right = crTreeOrgDims.right ;
  455. if (crTreeOrgDims.Height() > crTreeCurDims.Height()
  456. || crWSVOrgDims.Height() >= crWSVCurDims.Height())
  457. crTreeCurDims.bottom = crTreeOrgDims.bottom ;
  458. m_ctcDriver.MoveWindow(crTreeCurDims, TRUE) ;
  459. // Now, do the same thing for the label. The one difference is that only
  460. // label's width is allowed to change.
  461. crLblCurDims.right += ndx ;
  462. if (crLblOrgDims.Width() > crLblCurDims.Width()
  463. || crWSVOrgDims.Width() >= crWSVCurDims.Width())
  464. crLblCurDims.right = crLblOrgDims.right ;
  465. HWND hlblhandle ;
  466. GetDlgItem(IDC_ProjectLabel, &hlblhandle) ;
  467. ::MoveWindow(hlblhandle, crLblCurDims.left, crLblCurDims.top,
  468. crLblCurDims.Width(), crLblCurDims.Height(), TRUE) ;
  469. }
  470. /////////////////////////////////////////////////////////////////////////////
  471. // CCopyItem dialog
  472. CCopyItem::CCopyItem(CWnd* pParent /*=NULL*/)
  473. : CDialog(CCopyItem::IDD, pParent)
  474. {
  475. //{{AFX_DATA_INIT(CCopyItem)
  476. m_csCopyName = _T("");
  477. m_csCopyPrompt = _T("");
  478. //}}AFX_DATA_INIT
  479. }
  480. void CCopyItem::DoDataExchange(CDataExchange* pDX)
  481. {
  482. CDialog::DoDataExchange(pDX);
  483. //{{AFX_DATA_MAP(CCopyItem)
  484. DDX_Text(pDX, IDC_CopyName, m_csCopyName);
  485. DDX_Text(pDX, IDC_CopyPrompt, m_csCopyPrompt);
  486. //}}AFX_DATA_MAP
  487. }
  488. BEGIN_MESSAGE_MAP(CCopyItem, CDialog)
  489. //{{AFX_MSG_MAP(CCopyItem)
  490. // NOTE: the ClassWizard will add message map macros here
  491. //}}AFX_MSG_MAP
  492. END_MESSAGE_MAP()
  493. /////////////////////////////////////////////////////////////////////////////
  494. // CCopyItem message handlers
  495. void CCopyItem::Init(CString cssrcfile)
  496. {
  497. // Build the copy prompt string.
  498. m_csCopyPrompt.Format(IDS_CopyPrompt, cssrcfile) ;
  499. }
  500. /////////////////////////////////////////////////////////////////////////////
  501. // CChangeID dialog
  502. CChangeID::CChangeID(CWnd* pParent /*=NULL*/)
  503. : CDialog(CChangeID::IDD, pParent)
  504. {
  505. //{{AFX_DATA_INIT(CChangeID)
  506. m_csResourceLabel = _T("");
  507. m_csResourceName = _T("");
  508. m_nCurResID = 0;
  509. m_nNewResID = 0;
  510. //}}AFX_DATA_INIT
  511. }
  512. void CChangeID::DoDataExchange(CDataExchange* pDX)
  513. {
  514. CDialog::DoDataExchange(pDX);
  515. //{{AFX_DATA_MAP(CChangeID)
  516. DDX_Text(pDX, IDC_ResourceLabel, m_csResourceLabel);
  517. DDX_Text(pDX, IDC_ResourceName, m_csResourceName);
  518. DDX_Text(pDX, IDC_CurResID, m_nCurResID);
  519. DDX_Text(pDX, IDC_NewResID, m_nNewResID);
  520. DDV_MinMaxInt(pDX, m_nNewResID, 1, 999999);
  521. //}}AFX_DATA_MAP
  522. }
  523. BEGIN_MESSAGE_MAP(CChangeID, CDialog)
  524. //{{AFX_MSG_MAP(CChangeID)
  525. //}}AFX_MSG_MAP
  526. END_MESSAGE_MAP()
  527. /////////////////////////////////////////////////////////////////////////////
  528. // CChangeID message handlers
  529. void CChangeID::Init(CString csrestype, CString csname, int ncurid)
  530. {
  531. m_csResourceLabel.Format(IDS_ResourceLabel, csrestype) ;
  532. m_csResourceName = csname ;
  533. m_nCurResID = ncurid ;
  534. }
  535. /******************************************************************************
  536. CDeleteQuery dialog
  537. This implements the dialog that validates and verifies the removal of a
  538. file from the workspace.
  539. ******************************************************************************/
  540. CDeleteQuery::CDeleteQuery(CWnd* pParent /*=NULL*/)
  541. : CDialog(CDeleteQuery::IDD, pParent) {
  542. //{{AFX_DATA_INIT(CDeleteQuery)
  543. m_csTarget = _T("");
  544. m_bRemoveFile = FALSE;
  545. //}}AFX_DATA_INIT
  546. }
  547. void CDeleteQuery::DoDataExchange(CDataExchange* pDX) {
  548. CDialog::DoDataExchange(pDX);
  549. //{{AFX_DATA_MAP(CDeleteQuery)
  550. DDX_Text(pDX, IDC_DeletePrompt, m_csTarget);
  551. DDX_Check(pDX, IDC_Remove, m_bRemoveFile);
  552. //}}AFX_DATA_MAP
  553. }
  554. BEGIN_MESSAGE_MAP(CDeleteQuery, CDialog)
  555. //{{AFX_MSG_MAP(CDeleteQuery)
  556. ON_BN_CLICKED(IDNO, OnNo)
  557. ON_BN_CLICKED(IDYES, OnYes)
  558. //}}AFX_MSG_MAP
  559. END_MESSAGE_MAP()
  560. /////////////////////////////////////////////////////////////////////////////
  561. // CDeleteQuery message handlers
  562. void CDeleteQuery::Init(CString csrestype, CString csname)
  563. {
  564. m_csTarget.Format(IDS_DeletePrompt, csrestype, csname) ;
  565. }
  566. void CDeleteQuery::OnYes() {
  567. if (UpdateData())
  568. EndDialog(IDYES);
  569. }
  570. void CDeleteQuery::OnNo() {
  571. EndDialog(IDNO);
  572. }
  573. /******************************************************************************
  574. CProjectView::OnFileInf
  575. Called when the Generate INF command is selected on the File menu. This
  576. routine invokes the INF file generation wizard to collect input and generate
  577. the INF file. Then create and initialize a window to display the INF file.
  578. ******************************************************************************/
  579. void CProjectView::OnFileInf()
  580. {
  581. // INF files can only be generated for projects that contain models (GPDs).
  582. if (GetDocument()->ModelCount() == 0) {
  583. CString csmsg ;
  584. csmsg.LoadString(IDS_INFNoModelsError) ;
  585. AfxMessageBox(csmsg, MB_ICONEXCLAMATION) ;
  586. return ;
  587. } ;
  588. // Initialize the INF generation wizard.
  589. CINFWizard* pciw = new CINFWizard(this) ;
  590. // Invoke the INF generation wizard. Clean up and return if the user
  591. // cancels.
  592. if (pciw->DoModal() == IDCANCEL) {
  593. delete pciw ;
  594. return ;
  595. } ;
  596. // Generate the INF file based on the information collected.
  597. if (!pciw->GenerateINFFile()) {
  598. delete pciw ;
  599. return ;
  600. } ;
  601. // Allocate and initialize the document.
  602. CINFWizDoc* pciwd = new CINFWizDoc((CProjectRecord*) GetDocument(), pciw) ;
  603. // Create the window.
  604. CMDIChildWnd* pcmcwnew ;
  605. CMultiDocTemplate* pcmdt = INFViewerTemplate() ;
  606. pcmcwnew = (CMDIChildWnd *) pcmdt->CreateNewFrame(pciwd, NULL) ;
  607. // If the window was created, finish the initialization. Otherwise, just
  608. // return.
  609. if (pcmcwnew) {
  610. pcmdt->InitialUpdateFrame(pcmcwnew, pciwd, TRUE) ;
  611. pcmdt->AddDocument(pciwd) ;
  612. } ;
  613. }