MainFrm.cpp
上传用户:szcysw
上传日期:2013-03-11
资源大小:6752k
文件大小:5k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "DevDemo.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)
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- 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()
- {
- }
- //使用CCJFrameWnd风格的窗口框架
- #define CFrameWnd CCJFrameWnd
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1;
- }
-
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1;
- }
-
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- CRect rect;
- this->GetClientRect(&rect);
-
- // 新建3个工作区
- //工作区一:依靠在左
- if( !m_wndWorkspace1.Create(this, ID_VIEW_WORKSPACE,
- _T("类查看器"), CSize(200,200), CBRS_LEFT ))
- {
- TRACE0("工作区1创建失败n");
- return -1;
- }
-
- /*工作区二:依靠在右,将其宽度设为1000,目的是让
- 工作区二能紧靠工作区一*/
- if( !m_wndWorkspace2.Create(this, ID_VIEW_WORKSPACE2,
- _T("文本编辑框"), CSize(1000,200), CBRS_RIGHT))
- {
- TRACE0("工作区2创建失败n");
- return -1;
- }
-
- //工作区三:依靠在下
- if( !m_wndWorkspace3.Create(this, ID_VIEW_WORKSPACE3,
- _T("超文本"), CSize(200,200), CBRS_BOTTOM ))
- {
- TRACE0("工作区3创建失败n");
- return -1;
- }
-
- //设置标签使用的图片
- m_TabImages.Create( IDB_TAB, 16, 1, RGB( 0,255,0 ));
- m_wndWorkspace1.SetTabImageList( &m_TabImages );
- m_wndWorkspace2.SetTabImageList( &m_TabImages );
- m_wndWorkspace2.SetTabImageList( &m_TabImages );
-
- //对工作区1进行初始化
- CDevDemoApp * app;
- app=(CDevDemoApp * )AfxGetApp();
- //添加标签1
- m_pDocClass = DYNAMIC_DOWNCAST(CMyDoc, app->
- m_pClassDocTemplate->CreateNewDocument());
- ASSERT_KINDOF( CMyDoc, m_pDocClass );
- m_wndWorkspace1.AddView( _T( "标签1" ), RUNTIME_CLASS(CMyView ), m_pDocClass );
-
- //添加标签2
- m_pDocResource = DYNAMIC_DOWNCAST(CTreeDoc1, app->
- m_pResourceDocTemplate->CreateNewDocument());
- ASSERT_KINDOF( CTreeDoc1, m_pDocResource );
- m_wndWorkspace1.AddView( _T( "标签2" ), RUNTIME_CLASS( CTree2 ), m_pDocResource );
- //添加标签3
- m_pDocFile = DYNAMIC_DOWNCAST(CTreeDoc2, app->
- m_pFileDocTemplate->CreateNewDocument());
- ASSERT_KINDOF(CTreeDoc2, m_pDocFile );
- m_wndWorkspace1.AddView( _T( "标签3" ), RUNTIME_CLASS(CTree2), m_pDocFile );
-
- //对工作区2进行初始化
- m_wndWorkspace2.AddView( _T( "Debug" ), RUNTIME_CLASS(CMyView ), m_pDocClass );
- m_wndWorkspace2.AddView( _T( "Output" ), RUNTIME_CLASS(CMyView ), m_pDocClass );
- m_wndWorkspace2.AddView( _T( "FindInfiles" ), RUNTIME_CLASS(CMyView ), m_pDocClass );
-
- //对工作区3进行初始化
- m_pDocHtml=DYNAMIC_DOWNCAST(CHTMLDOC, app->m_htmlDoc->CreateNewDocument());
- ASSERT_KINDOF(CHTMLDOC, m_pDocHtml);
- m_wndWorkspace3.AddView( _T( "超文本浏览" ), RUNTIME_CLASS(CMyHTML), m_pDocHtml);
-
- //设置工作区的依靠对齐方式
- m_wndWorkspace1.EnableDockingOnSizeBar( CBRS_ALIGN_TOP|CBRS_ALIGN_LEFT );
- m_wndWorkspace2.EnableDockingOnSizeBar( CBRS_ALIGN_TOP|CBRS_ALIGN_RIGHT );
- m_wndWorkspace3.EnableDockingOnSizeBar( CBRS_ALIGN_BOTTOM);
- EnableDockingSizeBar( CBRS_ALIGN_ANY );
-
- //分别停靠三个工作区
- DockSizeBar( &m_wndWorkspace1 );
- DockSizeBar( &m_wndWorkspace2);
- DockSizeBar( &m_wndWorkspace3 );
-
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- cs.style = WS_OVERLAPPED|WS_CAPTION|WS_THICKFRAME|WS_SYSMENU|
- WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_MAXIMIZE;
- 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