home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 May / Disc 2 / PCU0503CD2.iso / Crystal / Samples / CPP / 32bit / Mycall / SELECTEV.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-18  |  6.1 KB  |  195 lines

  1. // SelectEvent.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "mycall.h"
  6. #include "MYCALLdc.h"
  7. #include "SelectEv.h"
  8. #include "routing.h"
  9.  
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // SelectEvent property page
  20.  
  21. IMPLEMENT_DYNCREATE(SelectEvent, CPropertyPage)
  22.  
  23. SelectEvent::SelectEvent() : CPropertyPage(SelectEvent::IDD)
  24. {
  25.     //{{AFX_DATA_INIT(SelectEvent)
  26.     m_startstopEvent = FALSE;
  27.     m_readingrecordEvent = FALSE;
  28.     m_printwindowbuttonEvent = FALSE;
  29.     m_drillEvent = FALSE;
  30.     m_closeprintwindowEvent = FALSE;
  31.     m_activateprintwindowEvent = FALSE;
  32.     //}}AFX_DATA_INIT
  33. }
  34.  
  35. SelectEvent::~SelectEvent()
  36. {
  37. }
  38.  
  39. void SelectEvent::DoDataExchange(CDataExchange* pDX)
  40. {
  41.     CPropertyPage::DoDataExchange(pDX);
  42.     //{{AFX_DATA_MAP(SelectEvent)
  43.     DDX_Control(pDX, IDC_FILELOCATION, m_fileLocation);
  44.     DDX_Control(pDX, IDC_CHECK9, m_logToWindow);
  45.     DDX_Control(pDX, IDC_CHECK16, m_logToFile);
  46.     DDX_Check(pDX, IDC_CHECK1, m_startstopEvent);
  47.     DDX_Check(pDX, IDC_CHECK10, m_readingrecordEvent);
  48.     DDX_Check(pDX, IDC_CHECK12, m_printwindowbuttonEvent);
  49.     DDX_Check(pDX, IDC_CHECK13, m_drillEvent);
  50.     DDX_Check(pDX, IDC_CHECK14, m_closeprintwindowEvent);
  51.     DDX_Check(pDX, IDC_CHECK15, m_activateprintwindowEvent);
  52.     //}}AFX_DATA_MAP
  53.     if(pDX->m_bSaveAndValidate){
  54.         m_crpeEventInfo.startStopEvent = m_startstopEvent;
  55.         m_crpeEventInfo.readingRecordEvent =  m_readingrecordEvent;
  56.         m_crpeEventInfo.printWindowButtonEvent = m_printwindowbuttonEvent;
  57.         m_crpeEventInfo.drillEvent = m_drillEvent;
  58.         m_crpeEventInfo.closePrintWindowEvent = m_closeprintwindowEvent;
  59.         m_crpeEventInfo.activatePrintWindowEvent =  m_activateprintwindowEvent;
  60.         m_crpeEventInfo.StructSize = PE_SIZEOF_ENABLE_EVENT_INFO;
  61.         if(PEEnableEvent((m_myCallDoc->m_crpeJob->GetJobHandle()), &m_crpeEventInfo))
  62.             // passing document object to obtain data and update the view
  63.             if(PESetEventCallback((m_myCallDoc->m_crpeJob->GetJobHandle()), MyCallBackProc, m_myCallDoc))
  64.                 m_myCallDoc->m_statusString = "Successful PESetEnableEvent & PESetEventCallback";
  65.             else
  66.                 m_myCallDoc->m_statusString.Format("PESetEventCallBack Error %d", m_myCallDoc->m_crpeJob->GetErrorCode() );
  67.         else
  68.             m_myCallDoc->m_statusString.Format("PEEnableEvent Error %d", m_myCallDoc->m_crpeJob->GetErrorCode() );
  69.  
  70.     }
  71.  
  72. }
  73.  
  74.  
  75. BEGIN_MESSAGE_MAP(SelectEvent, CPropertyPage)
  76.     //{{AFX_MSG_MAP(SelectEvent)
  77.     ON_BN_CLICKED(IDC_CHECK16, OnCheck16)
  78.     //}}AFX_MSG_MAP
  79. END_MESSAGE_MAP()
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. // SelectEvent message handlers
  83.  
  84. void SelectEvent::OnOK() 
  85. {
  86.     
  87.     
  88.      CPropertyPage::OnOK();
  89. }
  90.  
  91.  
  92. BOOL CALLBACK EXPORT MyCallBackProc(short eventnum, void *struct2, void *struct1)
  93. {
  94.  
  95.     CMYCALLDoc* myDoc = (CMYCALLDoc *)struct1;
  96.     POSITION pos;
  97.     CString retString;
  98.     CStringList tempList;
  99.     int strLength;
  100.     myDoc->m_elementCount++; // increment the sequence number
  101.     // obtain the string that will displayed relative to the event number
  102.     myDoc->CreateOutputString(tempList, eventnum, struct2, myDoc->m_elementCount);
  103.     // we must use cstringlist in case we have a field list or group list field of an event
  104.     if(myDoc->m_outputToFile)
  105.         for( pos = tempList.GetHeadPosition(); pos != NULL;)
  106.         {
  107.         
  108.          retString = tempList.GetNext( pos );
  109.         myDoc->m_fileOutput<< retString <<endl;
  110.     }    
  111.     if(myDoc->m_outputToWindow){
  112.     
  113.         for( pos = tempList.GetHeadPosition(); pos != NULL;)
  114.         {
  115.         
  116.          retString = tempList.GetNext( pos );
  117.          strLength = retString.GetLength();
  118.         if(strLength > myDoc->m_longestString){
  119.             // checking to see if we must increase the horizontal extent
  120.             myDoc->m_listBox->SetHorizontalExtent(strLength * 7);
  121.             myDoc->m_longestString = strLength;
  122.         }
  123.         myDoc->m_listBox->AddString(retString);
  124.         }
  125.         // setting the current selection so it is highlighted.
  126.     myDoc->m_listBox->SetCurSel((myDoc->m_listBox->GetCount() - 1));
  127.  
  128.     }    
  129.     return TRUE;
  130. }
  131.  
  132. BOOL SelectEvent::OnInitDialog() 
  133. {
  134.     CPropertyPage::OnInitDialog();
  135.     m_crpeEventInfo.StructSize = PE_SIZEOF_ENABLE_EVENT_INFO;
  136.     PEGetEnableEventInfo((m_myCallDoc->m_crpeJob->GetJobHandle()), &m_crpeEventInfo);
  137.     m_startstopEvent = m_crpeEventInfo.startStopEvent;
  138.     m_readingrecordEvent= m_crpeEventInfo.readingRecordEvent;
  139.     m_printwindowbuttonEvent = m_crpeEventInfo.printWindowButtonEvent;
  140.     m_drillEvent = m_crpeEventInfo.drillEvent;
  141.     m_closeprintwindowEvent = m_crpeEventInfo.closePrintWindowEvent;
  142.     m_activateprintwindowEvent = m_crpeEventInfo.activatePrintWindowEvent;
  143.     // TODO: Add extra initialization here
  144.     
  145.     return TRUE;  // return TRUE unless you set the focus to a control
  146.                   // EXCEPTION: OCX Property Pages should return FALSE
  147. }
  148.  
  149. BOOL SelectEvent::OnKillActive() 
  150. {
  151.     // TODO: Add your specialized code here and/or call the base class
  152.     // making sure that user has collected a logging destination
  153.     if(!(m_logToFile.GetCheck() + m_logToWindow.GetCheck())){
  154.         MessageBox("Please Enter a Logging Destination");
  155.         return FALSE;
  156.     }
  157.     m_myCallDoc->m_outputToFile = m_logToFile.GetCheck();
  158.     m_myCallDoc->m_outputToWindow = m_logToWindow.GetCheck();
  159.  
  160.         
  161.     return CPropertyPage::OnKillActive();
  162. }
  163.  
  164.  
  165. void SelectEvent::OnCheck16() 
  166. {
  167.     // TODO: Add your control notification handler code here
  168.     char* filterBuf;
  169.     int strLength;
  170.     CString fileType;
  171.     CString filterName;
  172.     fileType.LoadString(IDS_LOGTYPE);
  173.     filterName.LoadString(IDS_LOGFILTER);
  174.     strLength = fileType.GetLength(); 
  175.     filterBuf = new char[strLength + filterName.GetLength() + 4];
  176.  
  177.     CFileDialog fileDialog(FALSE);
  178.     lstrcpy(filterBuf,fileType);
  179.     lstrcpy(&filterBuf[strLength + 1], filterName);
  180.     lstrcat(&filterBuf[strLength + 1], "\0");
  181.  
  182.     fileDialog.m_ofn.lpstrFilter = filterBuf;
  183.         
  184.     if(fileDialog.DoModal() == IDOK){
  185.         CString windowText = "File: ";
  186.             m_myCallDoc->m_fileOutput.open(fileDialog.GetPathName(),ios::trunc);
  187.             m_logToFile.SetCheck(1);
  188.             windowText += fileDialog.GetPathName();
  189.             m_fileLocation.SetWindowText(windowText);
  190.     }
  191.     else
  192.         m_logToFile.SetCheck(0);
  193.         delete filterBuf;
  194. }
  195.