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

  1. // mainfrm.cpp : implementation of the CMainFrame class
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "chatter.h"
  15.  
  16. #include "mainfrm.h"
  17. #include "chatdoc.h"
  18. #include "chatvw.h"
  19. #include "sendvw.h"
  20.  
  21. #ifdef _DEBUG
  22. #undef THIS_FILE
  23. static char BASED_CODE THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMainFrame
  28.  
  29. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  30.  
  31. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  32.     //{{AFX_MSG_MAP(CMainFrame)
  33.         // NOTE - the ClassWizard will add and remove mapping macros here.
  34.         //    DO NOT EDIT what you see in these blocks of generated code !
  35.     ON_WM_CREATE()
  36.     //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // arrays of IDs used to initialize control bars
  41.  
  42. // toolbar buttons - IDs are command buttons
  43. static UINT BASED_CODE buttons[] =
  44. {
  45.     // same order as in the bitmap 'toolbar.bmp'
  46.     ID_FILE_NEW,
  47.     ID_FILE_SAVE,
  48.         ID_SEPARATOR,
  49.     ID_APP_ABOUT,
  50. };
  51.  
  52. static UINT BASED_CODE indicators[] =
  53. {
  54.     ID_SEPARATOR,           // status line indicator
  55.     ID_INDICATOR_CAPS,
  56.     ID_INDICATOR_NUM,
  57. };
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CMainFrame construction/destruction
  61.  
  62. CMainFrame::CMainFrame()
  63. {
  64. }
  65.  
  66. CMainFrame::~CMainFrame()
  67. {
  68. }
  69.  
  70. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  71. {
  72.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  73.         return -1;
  74.  
  75.     if (!m_wndToolBar.Create(this) ||
  76.         !m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
  77.         !m_wndToolBar.SetButtons(buttons,
  78.           sizeof(buttons)/sizeof(UINT)))
  79.     {
  80.         return -1;      // fail to create
  81.     }
  82.  
  83.     if (!m_wndStatusBar.Create(this) ||
  84.         !m_wndStatusBar.SetIndicators(indicators,
  85.           sizeof(indicators)/sizeof(UINT)))
  86.     {
  87.         return -1;      // fail to create
  88.     }
  89.  
  90. #ifdef _WIN32
  91.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  92.     EnableDocking(CBRS_ALIGN_ANY);
  93.     DockControlBar(&m_wndToolBar);
  94.  
  95.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
  96. #endif
  97.  
  98.     return 0;
  99. }
  100.  
  101. BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  102.     CCreateContext* pContext)
  103. {
  104.     if (m_wndSplitter.CreateStatic(this,2,1))
  105.     {
  106.         CRect rect;
  107.         GetClientRect(&rect);
  108.         CSize size = rect.Size();
  109.         size.cy-=150;
  110.         if (m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CChatView),size,pContext))
  111.         {
  112.             if (m_wndSplitter.CreateView(1,0,RUNTIME_CLASS(CSendView),CSize(0,0),pContext))
  113.             {
  114.                 SetActiveView((CView*)m_wndSplitter.GetPane(1,0));
  115.                 return TRUE;
  116.             }
  117.         }
  118.     }
  119.     return FALSE;
  120. }
  121.  
  122. /////////////////////////////////////////////////////////////////////////////
  123. // CMainFrame diagnostics
  124.  
  125. #ifdef _DEBUG
  126. void CMainFrame::AssertValid() const
  127. {
  128.     CFrameWnd::AssertValid();
  129. }
  130.  
  131. void CMainFrame::Dump(CDumpContext& dc) const
  132. {
  133.     CFrameWnd::Dump(dc);
  134. }
  135.  
  136. #endif //_DEBUG
  137.  
  138. /////////////////////////////////////////////////////////////////////////////
  139. // CMainFrame message handlers
  140.