WorkspaceView.cpp
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:5k
源码类别:

网格计算

开发平台:

Visual C++

  1. // WorkspaceView.cpp : implementation file
  2. #include "stdafx.h"
  3. #include "trfAgent.h"
  4. #include "mainfrm.h"
  5. #include "WorkspaceView.h"
  6. /////////////////////////////////////////////////////////////////////////////
  7. IMPLEMENT_DYNCREATE(CWorkspaceView, CView)
  8. CWorkspaceView::CWorkspaceView(){}
  9. CWorkspaceView::~CWorkspaceView(){}
  10. BEGIN_MESSAGE_MAP(CWorkspaceView, CView)
  11. //{{AFX_MSG_MAP(CWorkspaceView)
  12. ON_WM_CREATE()
  13. ON_NOTIFY(TCN_SELCHANGE, IDW_WORKSPACE_TAB, OnTabSelChange)
  14. ON_WM_SIZE()
  15. //}}AFX_MSG_MAP
  16. END_MESSAGE_MAP()
  17. // CWorkspaceView drawing
  18. void CWorkspaceView::OnDraw(CDC* pDC)
  19. {
  20. CDocument* pDoc = GetDocument();
  21. }
  22. // CWorkspaceView diagnostics
  23. #ifdef _DEBUG
  24. void CWorkspaceView::AssertValid() const
  25. {
  26. CView::AssertValid();
  27. }
  28. void CWorkspaceView::Dump(CDumpContext& dc) const
  29. {
  30. CView::Dump(dc);
  31. }
  32. #endif //_DEBUG
  33. /////////////////////////////////////////////////////////////////////////////
  34. int CWorkspaceView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  35. {
  36. if (CView::OnCreate(lpCreateStruct) == -1)
  37. return -1;
  38. this->EnableScrollBar(SB_BOTH, ESB_DISABLE_BOTH);
  39. //////////////////////////////////////////////////////////////////////////
  40. DWORD dwStyle = TCS_TABS | TCS_BOTTOM | TCS_TOOLTIPS | WS_CHILD | WS_VISIBLE;
  41. if (!m_TabSolExplorer.Create(dwStyle, CRect(0, 0, 0, 0), this, IDW_WORKSPACE_TAB))
  42. return -1;
  43. m_TabSolExplorer.SetFont(CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT)));
  44. //////////////////////////////////////////////////////////////////////////
  45. dwStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS ;
  46. if (!m_TreeForUsers.Create(dwStyle, CRect(0,0,0,0), this, 1))
  47. return -1;
  48. if (!m_TreeForHistory.Create(dwStyle, CRect(0,0,0,0), this, 2))
  49. return -1;
  50. if (!m_TreeForGrpSend.Create(dwStyle, CRect(0,0,0,0), this, 3))
  51. return -1;
  52. if (!m_TreeForFtp.Create(dwStyle, CRect(0,0,0,0), this, 4))
  53. return -1;
  54. if(!m_imgWorkspace.Create(IDB_WORKSPACE, 16, 4, RGB (255, 255, 255)))
  55. return -1;
  56. m_TabSolExplorer.SetImageList(&m_imgWorkspace);
  57. m_TabSolExplorer.InsertItem(0, _LoadString(IDS_WRKSPC_TAB_USERS).GetBuffer(0), 0);
  58. m_TabSolExplorer.InsertItem(1, _LoadString(IDS_WRKSPC_TAB_HISTORY).GetBuffer(0), 4);
  59. m_TabSolExplorer.InsertItem(2, _LoadString(IDS_WRKSPC_TAB_GRPSENING).GetBuffer(0), 8);
  60. m_TabSolExplorer.InsertItem(3, _LoadString(IDS_WRKSPC_TAB_FTP).GetBuffer(0), 6);
  61. //////////////////////////////////////////////////////////////////////////
  62. m_TreeForGrpSend.UpdateTreeForUserDatas();
  63. return 0;
  64. }
  65. //get current activity window.
  66. CWnd* CWorkspaceView::GetActiveWnd(void)
  67. {
  68. switch(this->m_TabSolExplorer.GetCurSel())
  69. {
  70. case 0:
  71. return &m_TreeForUsers;
  72. case 1:
  73. return &m_TreeForHistory;
  74. case 2:
  75. return &m_TreeForGrpSend;
  76. case 3:
  77. return &m_TreeForFtp;
  78. }
  79. return NULL;
  80. }
  81. //switch view.
  82. void CWorkspaceView::OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult)
  83. {
  84. int index = m_TabSolExplorer.GetCurSel();
  85. //////////////////////////////////////////////////////////////////////////
  86. switch(index) {
  87. case 0:
  88. {
  89. this->m_TreeForUsers.ShowWindow(SW_SHOW);
  90. this->m_TreeForHistory.ShowWindow(SW_HIDE);
  91. this->m_TreeForGrpSend.ShowWindow(SW_HIDE);
  92. this->m_TreeForFtp.ShowWindow(SW_HIDE);
  93. }
  94. break;
  95. case 1:
  96. {
  97. this->m_TreeForUsers.ShowWindow(SW_HIDE);
  98. this->m_TreeForHistory.ShowWindow(SW_SHOW);
  99. this->m_TreeForGrpSend.ShowWindow(SW_HIDE);
  100. this->m_TreeForFtp.ShowWindow(SW_HIDE);
  101. }
  102. break;
  103. case 2:
  104. {
  105. this->m_TreeForUsers.ShowWindow(SW_HIDE);
  106. this->m_TreeForHistory.ShowWindow(SW_HIDE);
  107. this->m_TreeForGrpSend.ShowWindow(SW_SHOW);
  108. this->m_TreeForFtp.ShowWindow(SW_HIDE);
  109. }
  110. break;
  111. case 3:
  112. {
  113. this->m_TreeForUsers.ShowWindow(SW_HIDE);
  114. this->m_TreeForHistory.ShowWindow(SW_HIDE);
  115. this->m_TreeForGrpSend.ShowWindow(SW_HIDE);
  116. this->m_TreeForFtp.ShowWindow(SW_SHOW);
  117. }
  118. break;
  119. default:
  120. return ;
  121. }
  122. this->OnSize(1, 1, 1);
  123. //////////////////////////////////////////////////////////////////////////
  124. CMainFrame *pmainfrm = (CMainFrame*)::AfxGetMainWnd();
  125. pmainfrm->m_pwndWorkFrame->m_pwndFileTransView->SwitchToView(index);
  126. *pResult = 0;
  127. }
  128. void CWorkspaceView::OnSize(UINT nType, int cx, int cy) 
  129. {
  130. CView::OnSize(nType, cx, cy);
  131. if(this->m_TabSolExplorer.GetSafeHwnd())
  132. {
  133. CRect rc, rctab, rcwnd;
  134. int tabheight = 3*GetSystemMetrics(SM_CXHTHUMB) / 2;
  135. this->GetClientRect(&rc);
  136. rctab = rcwnd = rc;
  137. rctab.top = rctab.bottom - tabheight;
  138. this->m_TabSolExplorer.MoveWindow(&rctab, TRUE);
  139. CWnd *pwnd = this->GetActiveWnd();
  140. if(NULL != pwnd && NULL != pwnd->GetSafeHwnd())
  141. {
  142. rcwnd.bottom -= tabheight;
  143. pwnd->MoveWindow(&rcwnd, TRUE);
  144. }
  145. }
  146. this->ShowScrollBar(SB_BOTH, FALSE);
  147. }