home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c07 / lab02 / ex03 / mainfrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.4 KB  |  147 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "diff.h"
  6.  
  7. #include "splitter.h"
  8. #include "MainFrm.h"
  9. #include "diffdoc.h"
  10. #include "diffview.h"
  11.  
  12. #ifdef _DEBUG
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CMainFrame
  19.  
  20. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  21.  
  22. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  23.     //{{AFX_MSG_MAP(CMainFrame)
  24.         // NOTE - the ClassWizard will add and remove mapping macros here.
  25.         //    DO NOT EDIT what you see in these blocks of generated code !
  26.     ON_WM_CREATE()
  27.     //}}AFX_MSG_MAP
  28. END_MESSAGE_MAP()
  29.  
  30. static UINT indicators[] =
  31. {
  32.     ID_SEPARATOR,           // status line indicator
  33.     ID_INDICATOR_CAPS,
  34.     ID_INDICATOR_NUM,
  35.     ID_INDICATOR_SCRL,
  36. };
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CMainFrame construction/destruction
  40.  
  41. CMainFrame::CMainFrame()
  42. {
  43.     // TODO: add member initialization code here
  44.     
  45. }
  46.  
  47. CMainFrame::~CMainFrame()
  48. {
  49. }
  50.  
  51. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  52. {
  53.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  54.         return -1;
  55.     
  56.     if (!m_wndToolBar.Create(this) ||
  57.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  58.     {
  59.         TRACE0("Failed to create toolbar\n");
  60.         return -1;      // fail to create
  61.     }
  62.  
  63.     if (!m_wndStatusBar.Create(this) ||
  64.         !m_wndStatusBar.SetIndicators(indicators,
  65.           sizeof(indicators)/sizeof(UINT)))
  66.     {
  67.         TRACE0("Failed to create status bar\n");
  68.         return -1;      // fail to create
  69.     }
  70.  
  71.     // TODO: Delete these three lines if you don't want the toolbar to
  72.     //  be dockable
  73.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  74.     EnableDocking(CBRS_ALIGN_ANY);
  75.     DockControlBar(&m_wndToolBar);
  76.  
  77.     // TODO: Remove this if you don't want tool tips
  78.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  79.         CBRS_TOOLTIPS | CBRS_FLYBY);
  80.  
  81.     return 0;
  82. }
  83.  
  84. BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  85.     CCreateContext* pContext)
  86. {
  87.         //
  88.         //    For the difference application, we will create a
  89.         //    static splitter window    with 2 side by side panes.
  90.         //    
  91.     if(!m_wndSplitter.CreateStatic(this,1,2,WS_CHILD))
  92.     {
  93.         return FALSE;
  94.     }
  95.  
  96.     SIZE size;                                  
  97.     CRect rect;     
  98.     GetClientRect(&rect);   
  99.         
  100.         //
  101.         //    Calculate the size of the splitter panes
  102.         //
  103.     size.cx = (rect.right - m_wndSplitter.GetSplitterWidth())/2;
  104.     size.cy = rect.bottom;
  105.  
  106.         //
  107.         //    Provide each pane with its own view, the same in this case
  108.         //    but could be different    
  109.         //
  110.     m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CDiffView),size, pContext);
  111.     m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CDiffView),size, pContext);
  112.  
  113.     //SetActiveView((CView *)m_wndSplitter.GetPane(0,1));
  114.   
  115.     m_wndSplitter.ShowWindow(SW_SHOWNORMAL);
  116.     m_wndSplitter.UpdateWindow();
  117.  
  118.     return TRUE;
  119. }
  120.  
  121. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  122. {
  123.     // TODO: Modify the Window class or styles here by modifying
  124.     //  the CREATESTRUCT cs
  125.  
  126.     return CFrameWnd::PreCreateWindow(cs);
  127. }
  128.  
  129. /////////////////////////////////////////////////////////////////////////////
  130. // CMainFrame diagnostics
  131.  
  132. #ifdef _DEBUG
  133. void CMainFrame::AssertValid() const
  134. {
  135.     CFrameWnd::AssertValid();
  136. }
  137.  
  138. void CMainFrame::Dump(CDumpContext& dc) const
  139. {
  140.     CFrameWnd::Dump(dc);
  141. }
  142.  
  143. #endif //_DEBUG
  144.  
  145. /////////////////////////////////////////////////////////////////////////////
  146. // CMainFrame message handlers
  147.