RightPaneFrame.cpp
上传用户:weimei12
上传日期:2022-08-11
资源大小:185k
文件大小:2k
源码类别:

Email客户端

开发平台:

Visual C++

  1. // RightPaneFrame.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "SimpleMail.h"
  5. #include "ListCtrlView.h"
  6. #include "EditCtrlView.h"
  7. #include "SplitterView.h"
  8. #include "RightPaneFrame.h"
  9. // CRightPaneFrame
  10. IMPLEMENT_DYNCREATE(CRightPaneFrame, CFrameWnd)
  11. CRightPaneFrame::CRightPaneFrame()
  12. {
  13. m_pSplitterView= NULL;
  14. }
  15. CRightPaneFrame::~CRightPaneFrame()
  16. {
  17. }
  18. BEGIN_MESSAGE_MAP(CRightPaneFrame, CFrameWnd)
  19. END_MESSAGE_MAP()
  20. // CRightPaneFrame message handlers
  21. BOOL CRightPaneFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
  22. {
  23. // TODO: Add your specialized code here and/or call the base class
  24. m_pSplitterView = new CSplitterView;
  25. m_pSplitterView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault, this, VIEW_SPLITTER, pContext);
  26. SetActiveView(m_pSplitterView);
  27. m_pSplitterView->ShowWindow(SW_SHOW);
  28. m_pSplitterView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
  29. m_nCurrentViewID = VIEW_SPLITTER;
  30. RecalcLayout();
  31. return TRUE;
  32. }
  33. void CRightPaneFrame::SwitchToView(UINT nView)
  34. {
  35. CView* pOldActiveView = GetActiveView();
  36. CView* pNewActiveView = NULL;
  37. switch (nView)
  38. {
  39. case VIEW_SPLITTER:
  40. pNewActiveView = (CView*) m_pSplitterView;
  41. break;
  42. case VIEW_LISTCTRL:
  43. pNewActiveView = (CView*) m_pSplitterView->m_pListCtrlView;
  44. break;
  45. case VIEW_EDIT:
  46. pNewActiveView = (CView*) m_pSplitterView->m_pEditCtrlView;
  47. break;
  48. default:
  49. ASSERT(FALSE);
  50. return;
  51. }
  52. if (pNewActiveView)
  53. {
  54. // don't switch when views are the same
  55. if (pOldActiveView == pNewActiveView) 
  56. {
  57. return;
  58. }
  59. SetActiveView(pNewActiveView);
  60. pNewActiveView->ShowWindow(SW_SHOW);
  61. pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
  62. pOldActiveView->ShowWindow(SW_HIDE);
  63. pOldActiveView->SetDlgCtrlID(m_nCurrentViewID);
  64. m_nCurrentViewID = nView;
  65. RecalcLayout();
  66. }
  67. }