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 / outwndvw.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.3 KB  |  109 lines

  1. // OutputWindowView.Cpp : implementation file
  2. //
  3.  
  4. #include "StdAfx.H"
  5. #include "TestCon.H"
  6.  
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // COutputWindowView
  15.  
  16. IMPLEMENT_DYNCREATE( COutputWindowView, CEditView )
  17.  
  18. COutputWindowView::COutputWindowView()
  19. {
  20. }
  21.  
  22. COutputWindowView::~COutputWindowView()
  23. {
  24. }
  25.  
  26.  
  27. BEGIN_MESSAGE_MAP(COutputWindowView, CEditView)
  28.     //{{AFX_MSG_MAP(COutputWindowView)
  29.     ON_WM_CREATE()
  30.     ON_WM_CONTEXTMENU()
  31.     //}}AFX_MSG_MAP
  32.    ON_COMMAND( ID_OUTPUTLOGEDIT_CLEAR, OnClear )
  33.    ON_COMMAND( ID_OUTPUTLOGEDIT_COPY, OnCopy )
  34. END_MESSAGE_MAP()
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // COutputWindowView drawing
  38.  
  39. void COutputWindowView::OnDraw( CDC* /* pDC */ )
  40. {
  41. }
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // COutputWindowView diagnostics
  45.  
  46. #ifdef _DEBUG
  47. void COutputWindowView::AssertValid() const
  48. {
  49.     CEditView::AssertValid();
  50. }
  51.  
  52. void COutputWindowView::Dump(CDumpContext& dc) const
  53. {
  54.     CEditView::Dump(dc);
  55. }
  56. #endif //_DEBUG
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. // COutputWindowView message handlers
  60.  
  61. int COutputWindowView::OnCreate( LPCREATESTRUCT pCreateStruct )
  62. {
  63.     if( CEditView::OnCreate( pCreateStruct ) == -1 )
  64.    {
  65.       return( -1 );
  66.    }
  67.  
  68.    m_font.CreatePointFont( 100, _T( "Courier" ) );
  69.    SetFont( &m_font );
  70.  
  71.    SendMessage( EM_SETREADONLY, TRUE, 0 );
  72.  
  73.     return( 0 );
  74. }
  75.  
  76. void COutputWindowView::OnContextMenu( CWnd* pWnd, CPoint point )
  77. {
  78.    CMenu menu;
  79.    CMenu* pPopupMenu;
  80.    int iStart;
  81.    int iEnd;
  82.  
  83.    if( pWnd->m_hWnd != m_hWnd )
  84.    {
  85.       return;
  86.    }
  87.  
  88.    menu.LoadMenu( IDR_OUTPUTLOGEDIT_CONTEXT );
  89.    pPopupMenu = menu.GetSubMenu( 0 );
  90.    GetEditCtrl().GetSel( iStart, iEnd );
  91.    if( iEnd == iStart )
  92.    {
  93.       pPopupMenu->EnableMenuItem( ID_OUTPUTLOGEDIT_COPY, MF_GRAYED );
  94.    }
  95.    pPopupMenu->TrackPopupMenu( TPM_LEFTALIGN|TPM_RIGHTBUTTON, point.x, point.y,
  96.       this, NULL );
  97.    menu.DestroyMenu();
  98. }
  99.  
  100. void COutputWindowView::OnClear()
  101. {
  102.    DeleteContents();
  103. }
  104.  
  105. void COutputWindowView::OnCopy()
  106. {
  107.    GetEditCtrl().Copy();
  108. }
  109.