home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / MFC / SAMPLES / VIEWEX / SPLITTER.CP_ / SPLITTER.CP
Encoding:
Text File  |  1993-02-08  |  4.2 KB  |  158 lines

  1. // splitter.cpp : implementation file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992 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 Microsoft
  9. // QuickHelp and/or WinHelp documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13.  
  14.  
  15. #include "stdafx.h"
  16. #include "viewex.h"
  17. #include "splitter.h"
  18.  
  19. #ifdef _DEBUG
  20. #undef THIS_FILE
  21. static char BASED_CODE THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CSplitterFrame
  26.  
  27. // Create a splitter window which splits an output text view and an input view
  28. //                           |
  29. //    TEXT VIEW (CTextView)  | INPUT VIEW (CInputView)
  30. //                           |
  31.  
  32. IMPLEMENT_DYNCREATE(CSplitterFrame, CMDIChildWnd)
  33.  
  34. CSplitterFrame::CSplitterFrame()
  35. {
  36. }
  37.  
  38. CSplitterFrame::~CSplitterFrame()
  39. {
  40. }
  41.  
  42.  
  43. BOOL CSplitterFrame::OnCreateClient(LPCREATESTRUCT,
  44.      CCreateContext* pContext)
  45. {
  46.     // create a splitter with 1 row, 2 columns
  47.     if (!m_wndSplitter.CreateStatic(this, 1, 2))
  48.     {
  49.         TRACE("Failed to CreateStaticSplitter\n");
  50.         return FALSE;
  51.     }
  52.  
  53.     // add the first splitter pane - the default view in column 0
  54.     if (!m_wndSplitter.CreateView(0, 0,
  55.         pContext->m_pNewViewClass, CSize(130, 50), pContext))
  56.     {
  57.         TRACE("Failed to create first pane\n");
  58.         return FALSE;
  59.     }
  60.  
  61.     // add the second splitter pane - an input view in column 1
  62.     if (!m_wndSplitter.CreateView(0, 1,
  63.         RUNTIME_CLASS(CInputView), CSize(0, 0), pContext))
  64.     {
  65.         TRACE("Failed to create second pane\n");
  66.         return FALSE;
  67.     }
  68.  
  69.     // activate the input view
  70.     SetActiveView((CView*)m_wndSplitter.GetPane(0,1));
  71.  
  72.     return TRUE;
  73. }
  74.  
  75. BEGIN_MESSAGE_MAP(CSplitterFrame, CMDIChildWnd)
  76.     //{{AFX_MSG_MAP(CSplitterFrame)
  77.     //}}AFX_MSG_MAP
  78. END_MESSAGE_MAP()
  79.  
  80. /////////////////////////////////////////////////////////////////////////////
  81. // C3WaySplitterFrame - just like CSplitterFrame except the input view is
  82. //   the first pane, and there are two output views
  83.  
  84. //                             |  Text View (CTextView)
  85. //    INPUT VIEW (CInputView)  |------------------------
  86. //                             |  Color View (CColorView)
  87.  
  88. IMPLEMENT_DYNCREATE(C3WaySplitterFrame, CMDIChildWnd)
  89.  
  90. C3WaySplitterFrame::C3WaySplitterFrame()
  91. {
  92. }
  93.  
  94. C3WaySplitterFrame::~C3WaySplitterFrame()
  95. {
  96. }
  97.  
  98.  
  99. BOOL C3WaySplitterFrame::OnCreateClient(LPCREATESTRUCT lpcs,
  100.      CCreateContext* pContext)
  101. {
  102.     // create a splitter with 1 row, 2 columns
  103.     if (!m_wndSplitter.CreateStatic(this, 1, 2))
  104.     {
  105.         TRACE("Failed to CreateStaticSplitter\n");
  106.         return FALSE;
  107.     }
  108.  
  109.     // add the first splitter pane - the default view in column 0
  110.     if (!m_wndSplitter.CreateView(0, 0,
  111.         pContext->m_pNewViewClass, CSize(200, 50), pContext))
  112.     {
  113.         TRACE("Failed to create first pane\n");
  114.         return FALSE;
  115.     }
  116.  
  117.     // add the second splitter pane - which is a nested splitter with 2 rows
  118.     if (!m_wndSplitter2.CreateStatic(
  119.         &m_wndSplitter,     // our parent window is the first splitter
  120.         2, 1,               // the new splitter is 2 rows, 1 column
  121.         WS_CHILD | WS_VISIBLE | WS_BORDER,  // style, WS_BORDER is needed
  122.         m_wndSplitter.IdFromRowCol(0, 1)
  123.             // new splitter is in the first row, 2nd column of first splitter
  124.        ))
  125.     {
  126.         TRACE("Failed to create nested splitter\n");
  127.         return FALSE;
  128.     }
  129.  
  130.     // now create the two views inside the nested splitter
  131.     int cyText = max(lpcs->cy - 70, 20);    // height of text pane
  132.  
  133.     if (!m_wndSplitter2.CreateView(0, 0,
  134.         RUNTIME_CLASS(CTextView), CSize(0, cyText), pContext))
  135.     {
  136.         TRACE("Failed to create second pane\n");
  137.         return FALSE;
  138.     }
  139.     if (!m_wndSplitter2.CreateView(1, 0,
  140.         RUNTIME_CLASS(CColorView), CSize(0, 0), pContext))
  141.     {
  142.         TRACE("Failed to create third pane\n");
  143.         return FALSE;
  144.     }
  145.  
  146.     // it all worked, we now have two splitter windows which contain
  147.     //  three different views
  148.     return TRUE;
  149. }
  150.  
  151. BEGIN_MESSAGE_MAP(C3WaySplitterFrame, CMDIChildWnd)
  152.     //{{AFX_MSG_MAP(C3WaySplitterFrame)
  153.     //}}AFX_MSG_MAP
  154. END_MESSAGE_MAP()
  155.  
  156. /////////////////////////////////////////////////////////////////////////////
  157.  
  158.