mainfrm.cpp
上传用户:liudazhe
上传日期:2007-01-02
资源大小:51k
文件大小:4k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- // This is a part of the Microsoft Foundation Classes C++ library.
- // Copyright (C) 1992-1997 Microsoft Corporation
- // All rights reserved.
- //
- // This source code is only intended as a supplement to the
- // Microsoft Foundation Classes Reference and related
- // electronic documentation provided with the library.
- // See these sources for detailed information regarding the
- // Microsoft Foundation Classes product.
- #include "stdafx.h"
- #include "MDI.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
- //{{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()
- {
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndToolBar.Create(this) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
- // set button styles for colors to TBBS_CHECKBOX
- m_wndToolBar.SetButtonStyle(6, TBBS_CHECKBOX);
- m_wndToolBar.SetButtonStyle(7, TBBS_CHECKBOX);
- m_wndToolBar.SetButtonStyle(10, TBBS_CHECKBOX);
- m_wndToolBar.SetButtonStyle(11, TBBS_CHECKBOX);
- m_wndToolBar.SetButtonStyle(12, TBBS_CHECKBOX);
- 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_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- if (!m_wndMenuBar.Create(this) ||
- !m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // faile to create
- }
- m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndMenuBar);
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- // Add title for toolbar
- m_wndToolBar.SetWindowText(_T("Standard"));
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- return CMDIFrameWnd::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CMDIFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CMDIFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
- {
- // TODO:
- if (m_wndMenuBar.TranslateFrameMessage(pMsg))
- return TRUE;
-
- return CMDIFrameWnd::PreTranslateMessage(pMsg);
- }
- void CMainFrame::ActivateFrame(int nCmdShow)
- {
- // TODO:
- // if App is SDI, maybe you can hide main frame until menu hidden by m_wndMenuBar.OnActivateFrame
- // m_wndMenuBar.OnActivateFrame(nCmdShow);
- CMDIFrameWnd::ActivateFrame(nCmdShow);
- }