MainFrm.cpp
上传用户:szcysw
上传日期:2013-03-11
资源大小:6752k
文件大小:7k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "MyExplorer.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code !
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- ON_COMMAND(ID_BACK, OnBack)
- ON_COMMAND(ID_FORWARD, OnForward)
- ON_COMMAND(ID_UP, OnUp)
- ON_COMMAND(ID_CUT, OnCut)
- ON_COMMAND(ID_COPY, OnCopy)
- ON_COMMAND(ID_PASTE, OnPaste)
- ON_COMMAND(ID_UNDO, OnUndo)
- ON_COMMAND(ID_DELETE, OnDelete)
- // ON_COMMAND(ID_PROPERTIES, OnProperties)
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
-
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- //装入自定义工具条
- if (!m_wndToolBar.CreateEx(this) ||
- !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1))
- {
- AfxMessageBox("Failed to create toolbarn");
- return -1; // fail to create
- }
-
- //实现彩色位图
- CString str;
- CImageList imageList;
- CBitmap bitmap;
- bitmap.LoadBitmap(IDB_COLDTOOLBAR);
- imageList.Create(22, 20, ILC_COLORDDB|ILC_MASK, 13, 1);
- imageList.Add(&bitmap, RGB(255,0,255));
- m_wndToolBar.GetToolBarCtrl().SetImageList(&imageList);
- imageList.Detach();
- bitmap.Detach();
-
- //分别为每一个按钮添加文本标题
- str.LoadString(IDS_BACK);
- m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_BACK), str);
- str.LoadString(IDS_FORWARD);
- m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_FORWARD), str);
- str.LoadString(IDS_UP);
- m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_UP), str);
- str.LoadString(IDS_CUT);
- m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_CUT), str);
- str.LoadString(IDS_COPY);
- m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_COPY), str);
- str.LoadString(IDS_PASTE);
- m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_PASTE), str);
- str.LoadString(IDS_UNDO);
- m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_UNDO), str);
- str.LoadString(IDS_DELETE);
- m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_DELETE), str);
- str.LoadString(IDS_PROPERTIES);
- m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_PROPERTIES), str);
- str.LoadString(IDS_TOGGLE);
- m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_VIEW_TOGGLE), str);
- //在按钮旁边添加下拉按钮
- m_wndToolBar.AddDropDownButton(ID_PROPERTIES, IDR_POPDOWN, TRUE);
- m_wndToolBar.AddDropDownButton(ID_VIEW_TOGGLE, IDR_POPDOWN, TRUE);
- m_wndToolBar.GetToolBarCtrl().SetButtonWidth(50, 150);
- CRect rectToolBar;
- m_wndToolBar.GetItemRect(0, &rectToolBar);
- //设置工具条按钮大小
- m_wndToolBar.SetSizes(rectToolBar.Size(), CSize(22,20));
- m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY);
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- AfxMessageBox("Failed to create status barn");
- return -1; // fail to create
- }
- //建立地址栏
- if (!m_wndAddress.Create(CBS_DROPDOWN | WS_CHILD,
- CRect(0, 0, 200, 120), this, AFX_IDW_TOOLBAR-1))
- {
- AfxMessageBox("Failed to create comboboxn");
- return -1;
- }
- //建立AVI播放控件
- if (!m_wndAnimate.Create(WS_CHILD | WS_VISIBLE | ACS_AUTOPLAY,
- CRect(0,0,100,100), this, AFX_IDW_TOOLBAR+2) ||
- !m_wndAnimate.Open(IDR_AVI1))
- {
- TRACE0("Failed to create animation control.n");
- return -1;
- }
- //将地址栏、AVI播放控件做为工具条添加到m_wndReBar中
- if (!m_wndReBar.Create(this) ||!m_wndReBar.AddBar
- (&m_wndAddress, "地址:", NULL, RBBS_BREAK)||
- !m_wndReBar.AddBar(&m_wndAnimate, NULL, NULL, RBBS_FIXEDBMP | RBBS_FIXEDSIZE))
- {
- return 0;
- }
-
- //设置m_wndReBar工具条外观
- m_wndReBar.SetBarStyle(m_wndReBar.GetBarStyle() |
- CBRS_BORDER_ANY |CBRS_FLYBY);
- m_wndReBar.SetBarStyle(m_wndReBar.GetBarStyle() |
- CBRS_BORDER_ANY );
-
- //启用工具条停靠
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
-
- //将两个视图关联
- CCJShellList& listCtrl = GetRightPane()->m_ShellList;
- CCJShellTree& treeCtrl = GetLeftPane()->m_ShellTree;
- listCtrl.AssociateTree(&treeCtrl);
- treeCtrl.AssociateList(&listCtrl);
- treeCtrl.AssociateCombo(&m_wndAddress);
- return 0;
- //CCJShellTree& treeCtrl = pFrame->GetLeftPane()->GetTreeCtrl();
- treeCtrl.TunnelTree(_T("C:\"));
- }
- #include "left.h"
- #include "right.h"
- //将窗口切分成2列
- BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
- CCreateContext* pContext)
- {
- if (!m_wndSplitter.CreateStatic(this, 1, 2))
- return FALSE;
- if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeft), CSize(200, 100), pContext) ||
- !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRight), CSize(100, 100), pContext))
- {
- m_wndSplitter.DestroyWindow();
- return FALSE;
- }
- return TRUE;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- CLeft* CMainFrame::GetLeftPane()
- {
- CWnd* pWnd = m_wndSplitter.GetPane(0, 0);
- CLeft* pView = DYNAMIC_DOWNCAST(CLeft, pWnd);
- return pView;
- }
- CRight* CMainFrame::GetRightPane()
- {
- CWnd* pWnd = m_wndSplitter.GetPane(0, 1);
- CRight* pView = DYNAMIC_DOWNCAST(CRight, pWnd);
- return pView;
- }
- void CMainFrame::OnBack()
- {
- // TODO: Add your command handler code here
-
- }
- void CMainFrame::OnForward()
- {
- // TODO: Add your command handler code here
-
- }
- void CMainFrame::OnUp()
- {
- // TODO: Add your command handler code here
-
- }
- void CMainFrame::OnCut()
- {
- // TODO: Add your command handler code here
-
- }
- void CMainFrame::OnCopy()
- {
- // TODO: Add your command handler code here
-
- }
- void CMainFrame::OnPaste()
- {
- // TODO: Add your command handler code here
- }
- void CMainFrame::OnUndo()
- {
- // TODO: Add your command handler code here
-
- }
- void CMainFrame::OnDelete()
- {
- // TODO: Add your command handler code here
-
- }
- /*void CMainFrame::OnProperties()
- {
- // TODO: Add your command handler code here
-
- }
- void CMainFrame::OnViewToggle()
- {
- // TODO: Add your command handler code here
-
- }
- */