?? mainfrm.cpp
字號:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "StateCollection.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()
ON_COMMAND(ID_SAVE_DEBUG_CONF, OnSaveDebugConf)
ON_COMMAND(ID_LOAD_DEBUG_CONF, OnLoadDebugConf)
ON_COMMAND(ID_SAVE_REGULAR_CONF, OnSaveRegularConf)
ON_COMMAND(ID_LOAD_REGULAR_CONF, OnLoadRegularConf)
//}}AFX_MSG_MAP
ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize)
ON_REGISTERED_MESSAGE(BCGM_RESETTOOLBAR, OnToolbarReset)
ON_REGISTERED_MESSAGE(BCGM_TOOLBARMENU, OnToolbarContextMenu)
ON_COMMAND(ID_VIEW_WORKSPACE, OnViewWorkspace)
ON_UPDATE_COMMAND_UI(ID_VIEW_WORKSPACE, OnUpdateViewWorkspace)
ON_COMMAND(ID_VIEW_OUTPUT, OnViewOutput)
ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT, OnUpdateViewOutput)
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;
CBCGToolBar::EnableQuickCustomization ();
CBCGToolBar::SetLook2000 ();
// TODO: Define your own basic commands. Be sure, that each pulldown
// menu have at least one basic command.
CList<UINT, UINT> lstBasicCommands;
lstBasicCommands.AddTail (ID_VIEW_TOOLBARS);
lstBasicCommands.AddTail (ID_FILE_NEW);
lstBasicCommands.AddTail (ID_FILE_OPEN);
lstBasicCommands.AddTail (ID_FILE_SAVE);
lstBasicCommands.AddTail (ID_FILE_PRINT);
lstBasicCommands.AddTail (ID_APP_EXIT);
lstBasicCommands.AddTail (ID_EDIT_CUT);
lstBasicCommands.AddTail (ID_EDIT_PASTE);
lstBasicCommands.AddTail (ID_EDIT_UNDO);
lstBasicCommands.AddTail (ID_APP_ABOUT);
lstBasicCommands.AddTail (ID_VIEW_TOOLBAR);
lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE);
lstBasicCommands.AddTail (ID_LOAD_DEBUG_CONF);
lstBasicCommands.AddTail (ID_LOAD_REGULAR_CONF);
lstBasicCommands.AddTail (ID_SAVE_DEBUG_CONF);
lstBasicCommands.AddTail (ID_SAVE_REGULAR_CONF);
CBCGToolBar::SetBasicCommands (lstBasicCommands);
if (!m_wndMenuBar.Create (this))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle() | CBRS_SIZE_DYNAMIC);
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 toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
if (!m_wndWorkSpace.Create (_T("Workspace"), this, CSize (200, 200),
TRUE /* Has gripper */, ID_VIEW_WORKSPACE,
WS_CHILD | WS_VISIBLE | CBRS_LEFT))
{
TRACE0("Failed to create workspace bar\n");
return -1; // fail to create
}
if (!m_wndOutput.Create (_T("Output"), this, CSize (150, 150),
TRUE /* Has gripper */, ID_VIEW_OUTPUT,
WS_CHILD | WS_VISIBLE | CBRS_BOTTOM))
{
TRACE0("Failed to create output bar\n");
return -1; // fail to create
}
CString strMainToolbarTitle;
strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR);
m_wndToolBar.SetWindowText (strMainToolbarTitle);
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndWorkSpace.EnableDocking(CBRS_ALIGN_ANY);
m_wndOutput.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndMenuBar);
DockControlBar(&m_wndToolBar);
DockControlBar(&m_wndWorkSpace);
DockControlBar(&m_wndOutput);
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
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
void CMainFrame::OnViewCustomize()
{
//------------------------------------
// Create a customize toolbars dialog:
//------------------------------------
CBCGToolbarCustomize* pDlgCust = new CBCGToolbarCustomize (this,
TRUE /* Automatic menus scaning */);
pDlgCust->Create ();
}
LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp)
{
CPoint point (BCG_GET_X_LPARAM(lp), BCG_GET_Y_LPARAM(lp));
CMenu menu;
VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CBCGPopupMenu* pPopupMenu = new CBCGPopupMenu;
pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ());
return 0;
}
afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM)
{
// TODO: reset toolbar with id = (UINT) wp to its initial state:
//
// UINT uiToolBarId = (UINT) wp;
// if (uiToolBarId == IDR_MAINFRAME)
// {
// do something with m_wndToolBar
// }
return 0;
}
BOOL CMainFrame::OnShowPopupMenu (CBCGPopupMenu* pMenuPopup)
{
//---------------------------------------------------------
// Replace ID_VIEW_TOOLBARS menu item to the toolbars list:
//---------------------------------------------------------
CFrameWnd::OnShowPopupMenu (pMenuPopup);
if (pMenuPopup != NULL &&
pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0)
{
if (CBCGToolBar::IsCustomizeMode ())
{
//----------------------------------------------------
// Don't show toolbars list in the cuztomization mode!
//----------------------------------------------------
return FALSE;
}
pMenuPopup->RemoveAllItems ();
CMenu menu;
VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE);
}
return TRUE;
}
void CMainFrame::OnViewWorkspace()
{
ShowControlBar (&m_wndWorkSpace,
!(m_wndWorkSpace.GetStyle () & WS_VISIBLE),
FALSE);
RecalcLayout ();
}
void CMainFrame::OnUpdateViewWorkspace(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (m_wndWorkSpace.GetStyle () & WS_VISIBLE);
}
void CMainFrame::OnViewOutput()
{
ShowControlBar (&m_wndOutput,
!(m_wndOutput.GetStyle () & WS_VISIBLE),
FALSE);
RecalcLayout ();
}
void CMainFrame::OnUpdateViewOutput(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (m_wndOutput.GetStyle () & WS_VISIBLE);
}
void CMainFrame::OnSaveDebugConf()
{
theApp.SaveState (this, _T ("Debug"));
}
void CMainFrame::OnLoadDebugConf()
{
theApp.LoadState (this, _T ("Debug")) ;
}
void CMainFrame::OnSaveRegularConf()
{
theApp.SaveState (this, _T ("Regular")) ;
}
void CMainFrame::OnLoadRegularConf()
{
theApp.LoadState (this, _T ("Regular")) ;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -