home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / DYNASPLI.ZIP / MainFrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-03  |  3.5 KB  |  151 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DSplit.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "DynSplitView2.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CMainFrame
  18.  
  19. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  20.  
  21. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  22.     //{{AFX_MSG_MAP(CMainFrame)
  23.     ON_WM_CREATE()
  24.     ON_COMMAND(ID_DYNSPLIT, OnDynSplit)
  25.     ON_UPDATE_COMMAND_UI(ID_DYNSPLIT, OnUpdateDynSplit)
  26.     //}}AFX_MSG_MAP
  27. END_MESSAGE_MAP()
  28.  
  29. static UINT indicators[] =
  30. {
  31.     ID_SEPARATOR,           // status line indicator
  32.     ID_INDICATOR_CAPS,
  33.     ID_INDICATOR_NUM,
  34.     ID_INDICATOR_SCRL,
  35. };
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CMainFrame construction/destruction
  39.  
  40. CMainFrame::CMainFrame()
  41. {
  42.     // TODO: add member initialization code here
  43.     
  44. }
  45.  
  46. CMainFrame::~CMainFrame()
  47. {
  48. }
  49.  
  50. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  51. {
  52.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  53.         return -1;
  54.     
  55.     if (!m_wndToolBar.Create(this) ||
  56.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  57.     {
  58.         TRACE0("Failed to create toolbar\n");
  59.         return -1;      // fail to create
  60.     }
  61.  
  62.     if (!m_wndStatusBar.Create(this) ||
  63.         !m_wndStatusBar.SetIndicators(indicators,
  64.           sizeof(indicators)/sizeof(UINT)))
  65.     {
  66.         TRACE0("Failed to create status bar\n");
  67.         return -1;      // fail to create
  68.     }
  69.  
  70.     // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  71.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  72.         CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  73.  
  74.     // TODO: Delete these three lines if you don't want the toolbar to
  75.     //  be dockable
  76.     m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  77.     EnableDocking(CBRS_ALIGN_ANY);
  78.     DockControlBar(&m_wndToolBar);
  79.  
  80.     return 0;
  81. }
  82.  
  83. BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
  84.     CCreateContext* pContext)
  85. {
  86.     // create a splitter with 1 row, 2 columns
  87.     if (!m_wndSplitter.CreateStatic(this, 1, 2))
  88.     {
  89.         TRACE0("Failed to Splitter window\n");
  90.         return FALSE;
  91.     }
  92.  
  93.     // add the first splitter pane - the default view in column 0
  94.     if (!m_wndSplitter.CreateView(0, 0,
  95.         pContext->m_pNewViewClass, CSize(150, 150), pContext))
  96.     {
  97.         TRACE0("Failed to create first pane\n");
  98.         return FALSE;
  99.     }
  100.  
  101.     // add the second splitter pane - an input view in column 1
  102.     if (!m_wndSplitter.CreateView(0, 1,
  103.             RUNTIME_CLASS(CDynSplitView2), CSize(0, 0), pContext))
  104.     {
  105.         TRACE0("Failed to create second pane\n");
  106.         return FALSE;
  107.     }
  108.  
  109.     // activate the input view
  110.     SetActiveView((CView*)m_wndSplitter.GetPane(0,1));
  111.  
  112.     return TRUE;
  113. }
  114.  
  115. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  116. {
  117.     // TODO: Modify the Window class or styles here by modifying
  118.     //  the CREATESTRUCT cs
  119.  
  120.     return CFrameWnd::PreCreateWindow(cs);
  121. }
  122.  
  123. /////////////////////////////////////////////////////////////////////////////
  124. // CMainFrame diagnostics
  125.  
  126. #ifdef _DEBUG
  127. void CMainFrame::AssertValid() const
  128. {
  129.     CFrameWnd::AssertValid();
  130. }
  131.  
  132. void CMainFrame::Dump(CDumpContext& dc) const
  133. {
  134.     CFrameWnd::Dump(dc);
  135. }
  136.  
  137. #endif //_DEBUG
  138.  
  139. /////////////////////////////////////////////////////////////////////////////
  140. // CMainFrame message handlers
  141.  
  142. void CMainFrame::OnDynSplit() 
  143. {
  144.     m_wndSplitter.SetDynamic(!m_wndSplitter.IsDynamic());
  145. }
  146.  
  147. void CMainFrame::OnUpdateDynSplit(CCmdUI* pCmdUI) 
  148. {
  149.     pCmdUI->SetCheck(m_wndSplitter.IsDynamic());
  150. }
  151.