home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / tstcon / evlogpg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.4 KB  |  107 lines

  1. // EventLoggingPage.Cpp : implementation file
  2. //
  3.  
  4. #include "StdAfx.H"
  5. #include "TestCon.H"
  6. #include "resource.hm"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CEventLoggingPage property page
  16.  
  17. IMPLEMENT_DYNCREATE(CEventLoggingPage, CPropertyPage)
  18.  
  19. CEventLoggingPage::CEventLoggingPage() :
  20.    CPropertyPage( CEventLoggingPage::IDD )
  21. {
  22.    m_psp.dwFlags &= ~PSP_HASHELP;
  23.  
  24.     //{{AFX_DATA_INIT(CEventLoggingPage)
  25.         // NOTE: the ClassWizard will add member initialization here
  26.     //}}AFX_DATA_INIT
  27. }
  28.  
  29. CEventLoggingPage::~CEventLoggingPage()
  30. {
  31. }
  32.  
  33. void CEventLoggingPage::DoDataExchange(CDataExchange* pDX)
  34. {
  35.    int iEvent;
  36.    int iItem;
  37.  
  38.     CPropertyPage::DoDataExchange(pDX);
  39.     //{{AFX_DATA_MAP(CEventLoggingPage)
  40.     DDX_Control(pDX, IDC_EVENTS, m_lbEvents);
  41.     //}}AFX_DATA_MAP
  42.  
  43.    if( m_lbEvents.GetCount() > 0 )
  44.    {
  45.       for( iEvent = 0; iEvent < m_astrEventNames.GetSize(); iEvent++ )
  46.       {
  47.          iItem = m_lbEvents.FindStringExact( -1, m_astrEventNames[iEvent] );
  48.          ASSERT( iItem != LB_ERR );
  49.          if( pDX->m_bSaveAndValidate )
  50.          {
  51.             m_atLogFlags[iEvent] = m_lbEvents.GetCheck( iItem );
  52.          }
  53.          else
  54.          {
  55.  
  56.             m_lbEvents.SetCheck( iItem, m_atLogFlags[iEvent] != FALSE );
  57.          }
  58.       }
  59.    }
  60. }
  61.  
  62.  
  63. BEGIN_MESSAGE_MAP(CEventLoggingPage, CPropertyPage)
  64.     //{{AFX_MSG_MAP(CEventLoggingPage)
  65.     ON_WM_HELPINFO()
  66.     ON_WM_CONTEXTMENU()
  67.     //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CEventLoggingPage message handlers
  72.  
  73. BOOL CEventLoggingPage::OnInitDialog()
  74. {
  75.    int iEvent;
  76.  
  77.     CPropertyPage::OnInitDialog();
  78.  
  79.    for( iEvent = 0; iEvent < m_astrEventNames.GetSize(); iEvent++ )
  80.    {
  81.       m_lbEvents.AddString( m_astrEventNames[iEvent] );
  82.    }
  83.  
  84.    UpdateData( FALSE );
  85.  
  86.     return( TRUE );
  87. }
  88.  
  89. static DWORD rgmapCHID[] =
  90. {
  91.    IDC_EVENTS, HIDC_EVENTS,
  92.    0, 0
  93. };
  94.  
  95. BOOL CEventLoggingPage::OnHelpInfo( HELPINFO* pHelpInfo )
  96. {
  97.    return( ::WinHelp( HWND( pHelpInfo->hItemHandle ),
  98.       AfxGetApp()->m_pszHelpFilePath, HELP_WM_HELP, DWORD( LPVOID(
  99.       rgmapCHID ) ) ) );
  100. }
  101.  
  102. void CEventLoggingPage::OnContextMenu( CWnd* pWnd, CPoint /* point */ )
  103. {
  104.    ::WinHelp( HWND( *pWnd ), AfxGetApp()->m_pszHelpFilePath, HELP_CONTEXTMENU,
  105.       DWORD( LPVOID( rgmapCHID ) ) );
  106. }
  107.