home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / turbocad / v8trial / TurboCADv8ProfessionalNoReg.exe / Data.Cab / F38788_Begin.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-16  |  2.9 KB  |  108 lines

  1. /******************************************************************/
  2. /*                                                                */
  3. /*                      TurboCAD for Windows                      */
  4. /*                   Copyright (c) 1993 - 2001                    */
  5. /*             International Microcomputer Software, Inc.         */
  6. /*                            (IMSI)                              */
  7. /*                      All rights reserved.                      */
  8. /*                                                                */
  9. /******************************************************************/
  10.  
  11. // Begin.cpp : implementation file
  12. //
  13.  
  14. #include "stdafx.h"
  15. #include "resource.h"
  16. #include "Begin.h"
  17. #include "PaperSpaceWizard.h"
  18.  
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CBegin property page
  27.  
  28. IMPLEMENT_DYNCREATE(CBegin, CPropertyPage)
  29.  
  30. CBegin::CBegin() : CPropertyPage(CBegin::IDD)
  31. {
  32.     //{{AFX_DATA_INIT(CBegin)
  33.         // NOTE: the ClassWizard will add member initialization here
  34.     //}}AFX_DATA_INIT
  35. }
  36.  
  37. CBegin::~CBegin()
  38. {
  39. }
  40.  
  41. void CBegin::DoDataExchange(CDataExchange* pDX)
  42. {
  43.     CPropertyPage::DoDataExchange(pDX);
  44.     //{{AFX_DATA_MAP(CBegin)
  45.         // NOTE: the ClassWizard will add DDX and DDV calls here
  46.     //}}AFX_DATA_MAP
  47. }
  48.  
  49.  
  50. BEGIN_MESSAGE_MAP(CBegin, CPropertyPage)
  51.     //{{AFX_MSG_MAP(CBegin)
  52.         // NOTE: the ClassWizard will add message map macros here
  53.     //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CBegin message handlers
  58.  
  59. BOOL CBegin::OnSetActive() 
  60. {
  61.     CPaperSpaceWizard* pSheet = (CPaperSpaceWizard*)GetParent();
  62.     ASSERT_KINDOF(CPropertySheet, pSheet);
  63.     pSheet->SetWizardButtons( PSWIZB_NEXT);// | PSWIZB_FINISH);
  64.  
  65.     CEdit *pEdit = (CEdit *) GetDlgItem(IDC_EDITPSNAME);
  66.     pEdit->SetWindowText (pSheet->m_PSInfo->cstrPSpaceName);    
  67.     
  68.     return CPropertyPage::OnSetActive();
  69. }
  70.  
  71. LRESULT CBegin::OnWizardNext() 
  72. {
  73.     HRESULT hRes = E_FAIL;    
  74.     CString cstrTmp;
  75.     CString cstrErr;
  76.     COleVariant varName;
  77.     varName.vt = VT_BSTR;
  78.     PaperSpace *pPs = NULL;
  79.  
  80.     try
  81.     {
  82.  
  83.         CPaperSpaceWizard* pSheet = (CPaperSpaceWizard*)GetParent();
  84.         CEdit *pEdit = (CEdit *) GetDlgItem(IDC_EDITPSNAME);
  85.         pEdit->GetWindowText(cstrTmp);
  86.         varName.bstrVal  = cstrTmp.AllocSysString ();
  87. // try get PaperSpace fro PaperSpaces collection to define if PaperSpace with such name already exist        
  88.         hRes = pSheet->m_pPss->get_Item(&varName, &pPs);
  89.         if(FAILED(hRes))
  90.         {
  91.             pSheet->m_PSInfo->cstrPSpaceName = cstrTmp;            
  92.             cstrTmp.Empty ();
  93.             return CPropertyPage::OnWizardNext();
  94.         }
  95.         cstrErr.LoadString (IDS_ERRDUPLICATEPS);
  96.         AfxMessageBox(cstrErr);
  97.         pEdit->SetFocus ();
  98.         pEdit->SetSel(0, strlen(cstrTmp), FALSE);
  99.     }
  100.     catch(...)
  101.     {
  102.         TRACE("CBegin::OnWizardNext");    
  103.     }
  104.  
  105.     RELEASE(pPs)
  106.     return CPropertyPage::OnSetActive();
  107. }
  108.