MainFrm.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:4k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "MarkupPad.h"
- #include "MarkupPadEdit.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_MESSAGE(XTPWM_DOCKINGPANE_NOTIFY, OnDockingPaneNotify)
- 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;
-
- // Create Status bar.
- // Important: All control bars including the Status Bar
- // must be created before CommandBars....
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- m_wndStatusBar.EnableMarkup();
- // Initialize the command bars
- if (!InitCommandBars())
- return -1;
- // Get a pointer to the command bars object.
- CXTPCommandBars* pCommandBars = GetCommandBars();
- if(pCommandBars == NULL)
- {
- TRACE0("Failed to create command bars object.n");
- return -1; // fail to create
- }
- // Add the menu bar
- CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(
- _T("Menu Bar"), IDR_MAINFRAME);
- if(pMenuBar == NULL)
- {
- TRACE0("Failed to create menu bar.n");
- return -1; // fail to create
- }
- // Create ToolBar
- CXTPToolBar* pToolBar = (CXTPToolBar*)
- pCommandBars->Add(_T("Standard"), xtpBarTop);
- if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1;
- }
- pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault);
- // Set Office 2003 Theme
- CXTPPaintManager::SetTheme(xtpThemeWhidbey);
- m_paneManager.InstallDockingPanes(this);
- m_paneManager.SetTheme(xtpPaneThemeVisualStudio2005);
- CXTPDockingPane* pPaneEdit = m_paneManager.CreatePane(
- 1, CRect(0, 0,200, 200), xtpPaneDockBottom);
- pPaneEdit->SetTitle(_T("Markup"));
- pPaneEdit->SetOptions(xtpPaneNoCloseable);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if (!CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- cs.lpszClass = _T("XTPMainFrame");
- CXTPDrawHelpers::RegisterWndClass(AfxGetInstanceHandle(), cs.lpszClass,
- CS_DBLCLKS, AfxGetApp()->LoadIcon(IDR_MAINFRAME));
- 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
- LRESULT CMainFrame::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam)
- {
- if (wParam == XTP_DPN_SHOWWINDOW)
- {
- // get a pointer to the docking pane being shown.
- CXTPDockingPane* pPane = (CXTPDockingPane*)lParam;
- if (!pPane->IsValid())
- {
- pPane->Attach(m_pEditView);
- }
- return TRUE; // handled
- }
- return FALSE;
- }
- BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
- {
- if (!CFrameWnd::OnCreateClient(lpcs, pContext))
- return FALSE;
- pContext->m_pNewViewClass = RUNTIME_CLASS(CMarkupPadEdit);
- m_pEditView = (CView*)CreateView(pContext);
- m_pEditView->SetDlgCtrlID(0);
- return TRUE;
- }
- void CMainFrame::OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState)
- {
- // Toggle CommandBars
- GetCommandBars()->OnSetPreviewMode(bPreview);
- // Toggle Docking Panes.
- m_paneManager.OnSetPreviewMode(bPreview);
- CFrameWnd::OnSetPreviewMode(bPreview, pState);
- }