WorkspaceView.cpp
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:5k
- // WorkspaceView.cpp : implementation file
- #include "stdafx.h"
- #include "trfAgent.h"
- #include "mainfrm.h"
- #include "WorkspaceView.h"
- /////////////////////////////////////////////////////////////////////////////
- IMPLEMENT_DYNCREATE(CWorkspaceView, CView)
- CWorkspaceView::CWorkspaceView(){}
- CWorkspaceView::~CWorkspaceView(){}
- BEGIN_MESSAGE_MAP(CWorkspaceView, CView)
- //{{AFX_MSG_MAP(CWorkspaceView)
- ON_WM_CREATE()
- ON_NOTIFY(TCN_SELCHANGE, IDW_WORKSPACE_TAB, OnTabSelChange)
- ON_WM_SIZE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- // CWorkspaceView drawing
- void CWorkspaceView::OnDraw(CDC* pDC)
- {
- CDocument* pDoc = GetDocument();
- }
- // CWorkspaceView diagnostics
- #ifdef _DEBUG
- void CWorkspaceView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CWorkspaceView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- int CWorkspaceView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CView::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- this->EnableScrollBar(SB_BOTH, ESB_DISABLE_BOTH);
-
- //////////////////////////////////////////////////////////////////////////
-
- DWORD dwStyle = TCS_TABS | TCS_BOTTOM | TCS_TOOLTIPS | WS_CHILD | WS_VISIBLE;
-
- if (!m_TabSolExplorer.Create(dwStyle, CRect(0, 0, 0, 0), this, IDW_WORKSPACE_TAB))
- return -1;
-
- m_TabSolExplorer.SetFont(CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT)));
-
- //////////////////////////////////////////////////////////////////////////
-
- dwStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS ;
-
- if (!m_TreeForUsers.Create(dwStyle, CRect(0,0,0,0), this, 1))
- return -1;
-
- if (!m_TreeForHistory.Create(dwStyle, CRect(0,0,0,0), this, 2))
- return -1;
-
- if (!m_TreeForGrpSend.Create(dwStyle, CRect(0,0,0,0), this, 3))
- return -1;
-
- if (!m_TreeForFtp.Create(dwStyle, CRect(0,0,0,0), this, 4))
- return -1;
-
- if(!m_imgWorkspace.Create(IDB_WORKSPACE, 16, 4, RGB (255, 255, 255)))
- return -1;
-
- m_TabSolExplorer.SetImageList(&m_imgWorkspace);
- m_TabSolExplorer.InsertItem(0, _LoadString(IDS_WRKSPC_TAB_USERS).GetBuffer(0), 0);
- m_TabSolExplorer.InsertItem(1, _LoadString(IDS_WRKSPC_TAB_HISTORY).GetBuffer(0), 4);
- m_TabSolExplorer.InsertItem(2, _LoadString(IDS_WRKSPC_TAB_GRPSENING).GetBuffer(0), 8);
- m_TabSolExplorer.InsertItem(3, _LoadString(IDS_WRKSPC_TAB_FTP).GetBuffer(0), 6);
-
- //////////////////////////////////////////////////////////////////////////
-
- m_TreeForGrpSend.UpdateTreeForUserDatas();
-
- return 0;
- }
- //get current activity window.
- CWnd* CWorkspaceView::GetActiveWnd(void)
- {
- switch(this->m_TabSolExplorer.GetCurSel())
- {
- case 0:
- return &m_TreeForUsers;
- case 1:
- return &m_TreeForHistory;
- case 2:
- return &m_TreeForGrpSend;
- case 3:
- return &m_TreeForFtp;
- }
- return NULL;
- }
- //switch view.
- void CWorkspaceView::OnTabSelChange(NMHDR* pNMHDR, LRESULT* pResult)
- {
- int index = m_TabSolExplorer.GetCurSel();
-
- //////////////////////////////////////////////////////////////////////////
-
- switch(index) {
- case 0:
- {
- this->m_TreeForUsers.ShowWindow(SW_SHOW);
- this->m_TreeForHistory.ShowWindow(SW_HIDE);
- this->m_TreeForGrpSend.ShowWindow(SW_HIDE);
- this->m_TreeForFtp.ShowWindow(SW_HIDE);
- }
- break;
-
- case 1:
- {
- this->m_TreeForUsers.ShowWindow(SW_HIDE);
- this->m_TreeForHistory.ShowWindow(SW_SHOW);
- this->m_TreeForGrpSend.ShowWindow(SW_HIDE);
- this->m_TreeForFtp.ShowWindow(SW_HIDE);
- }
- break;
-
- case 2:
- {
- this->m_TreeForUsers.ShowWindow(SW_HIDE);
- this->m_TreeForHistory.ShowWindow(SW_HIDE);
- this->m_TreeForGrpSend.ShowWindow(SW_SHOW);
- this->m_TreeForFtp.ShowWindow(SW_HIDE);
- }
- break;
- case 3:
- {
- this->m_TreeForUsers.ShowWindow(SW_HIDE);
- this->m_TreeForHistory.ShowWindow(SW_HIDE);
- this->m_TreeForGrpSend.ShowWindow(SW_HIDE);
- this->m_TreeForFtp.ShowWindow(SW_SHOW);
- }
- break;
-
- default:
- return ;
- }
- this->OnSize(1, 1, 1);
- //////////////////////////////////////////////////////////////////////////
-
- CMainFrame *pmainfrm = (CMainFrame*)::AfxGetMainWnd();
- pmainfrm->m_pwndWorkFrame->m_pwndFileTransView->SwitchToView(index);
-
- *pResult = 0;
- }
- void CWorkspaceView::OnSize(UINT nType, int cx, int cy)
- {
- CView::OnSize(nType, cx, cy);
-
- if(this->m_TabSolExplorer.GetSafeHwnd())
- {
- CRect rc, rctab, rcwnd;
- int tabheight = 3*GetSystemMetrics(SM_CXHTHUMB) / 2;
-
- this->GetClientRect(&rc);
- rctab = rcwnd = rc;
- rctab.top = rctab.bottom - tabheight;
- this->m_TabSolExplorer.MoveWindow(&rctab, TRUE);
- CWnd *pwnd = this->GetActiveWnd();
- if(NULL != pwnd && NULL != pwnd->GetSafeHwnd())
- {
- rcwnd.bottom -= tabheight;
- pwnd->MoveWindow(&rcwnd, TRUE);
- }
- }
- this->ShowScrollBar(SB_BOTH, FALSE);
- }