Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
2.7 KiB

  1. // SplitterView.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ncbrowse.h"
  5. #include "SplitterView.h"
  6. #include "ncbrowsedoc.h"
  7. #include "NcbrowseView.h"
  8. #include "LeftView.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CSplitterView
  16. IMPLEMENT_DYNCREATE(CSplitterView, CView)
  17. CSplitterView::CSplitterView()
  18. {
  19. m_bInitialized = FALSE;
  20. m_bShouldSetXColumn = TRUE;
  21. }
  22. CSplitterView::~CSplitterView()
  23. {
  24. }
  25. BEGIN_MESSAGE_MAP(CSplitterView, CView)
  26. //{{AFX_MSG_MAP(CSplitterView)
  27. ON_WM_CREATE()
  28. ON_WM_SIZE()
  29. //}}AFX_MSG_MAP
  30. END_MESSAGE_MAP()
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CSplitterView drawing
  33. void CSplitterView::OnDraw(CDC* pDC)
  34. {
  35. CDocument* pDoc = GetDocument();
  36. // TODO: add draw code here
  37. }
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CSplitterView diagnostics
  40. #ifdef _DEBUG
  41. void CSplitterView::AssertValid() const
  42. {
  43. CView::AssertValid();
  44. }
  45. void CSplitterView::Dump(CDumpContext& dc) const
  46. {
  47. CView::Dump(dc);
  48. }
  49. #endif //_DEBUG
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CSplitterView message handlers
  52. int CSplitterView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  53. {
  54. if (CView::OnCreate(lpCreateStruct) == -1)
  55. return -1;
  56. CCreateContext* pContext = (CCreateContext*)lpCreateStruct->lpCreateParams;
  57. lpCreateStruct->style |= WS_OVERLAPPED;
  58. if (!m_wndSplitterLR.CreateStatic(this, 1, 2))
  59. return -1;
  60. if (!m_wndSplitterLR.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(225, 100), pContext) ||
  61. !m_wndSplitterLR.CreateView(0, 1, RUNTIME_CLASS(CNcbrowseView), CSize(225, 100), pContext))
  62. {
  63. m_wndSplitterLR.DestroyWindow();
  64. return -1;
  65. }
  66. return 0;
  67. }
  68. void CSplitterView::OnInitialUpdate()
  69. {
  70. CView::OnInitialUpdate();
  71. //Because of the structure of this app, this function can be called more than once.
  72. //The following flag insures the code after is only run once:
  73. if(m_bInitialized)
  74. return;
  75. m_bInitialized = true;
  76. }
  77. void CSplitterView::OnSize(UINT nType, int cx, int cy)
  78. {
  79. CView::OnSize(nType, cx, cy);
  80. m_wndSplitterLR.MoveWindow(0, 0, cx, cy);
  81. //We just want to set the X column upon creation of the view. This way the user can
  82. //move the splitter bar to how they like it and still resize the frame window
  83. //without it snapping back:
  84. if (m_bShouldSetXColumn)
  85. {
  86. m_wndSplitterLR.SetColumnInfo(0, cx/3, 0);
  87. m_bShouldSetXColumn = FALSE;
  88. }
  89. m_wndSplitterLR.RecalcLayout();
  90. }