📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "DutComputerManager.h"
#include "TabBrowseDoc.h"
#include "TabBrowseView.h"
#include "TabManagerDoc.h"
#include "TabManagerView.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CCJMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CCJMDIFrameWnd)
ON_COMMAND_EX(ID_VIEW_WORKSPACE, OnBarCheck)
ON_UPDATE_COMMAND_UI(ID_VIEW_WORKSPACE, OnUpdateControlBarMenu)
ON_COMMAND_EX(ID_VIEW_OUTPUT, OnBarCheck)
ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT, OnUpdateControlBarMenu)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_WM_CLOSE()
ON_COMMAND(ID_SHOW_ALLCOLLUM, OnShowAllcollum)
ON_UPDATE_COMMAND_UI(ID_SHOW_ALLCOLLUM, OnUpdateShowAllcollum)
ON_COMMAND(IDC_CLEAR_MESSAGE, OnClearMessage)
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE(WM_OUTLISTINFO_MESSAGE,OnListInfo)
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
m_bFlat = TRUE;
m_bShowall=FALSE;
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CCJMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
m_menu.Install(this);
m_menu.LoadToolbar(IDR_MAINFRAME);
CCJCoolMenu::m_bXpMode = TRUE;
if (!m_wndMenuBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0,0,0,0)) ||
!m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME))
{
TRACE("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE("Failed to create status bar\n");
return -1; // fail to create
}
// 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);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndMenuBar);
DockControlBar(&m_wndToolBar);
// Create the "Workspace" docking window.
{
// Initialize dialog bar m_wndWorkspace
if( !m_wndWorkspace.Create(this, ID_VIEW_WORKSPACE,
_T("Workspace"), CSize(225,100), CBRS_LEFT ))
{
TRACE0("Failed to create dialog bar m_wndWorkspace\n");
return -1; // fail to create
}
// Create the document for each of the tab views, then add the
// document / view to the tab control. This is a very simple implementation.
// you could go further and actually create a document template for each tab,
// and add it to the app. If so, you would pass in m_pMyDocTemplate->CreateNewDocument(),
// instead of dynamically allocating a pointer for each document as shown here.
// This was done for simplicity.
// class tab
m_pDocBrowse = new CTabBrowseDoc;
ASSERT_KINDOF( CDocument, m_pDocBrowse );
m_wndWorkspace.AddView( _T( "浏览录入" ), RUNTIME_CLASS( CTabBrowseView ), m_pDocBrowse );
m_pDocManager = new CTabManagerDoc;
ASSERT_KINDOF( CDocument, m_pDocManager );
m_wndWorkspace.AddView( _T( "资材管理" ), RUNTIME_CLASS( CTabManagerView ), m_pDocManager );
// Define the image list to use with the tab control
m_TabImages.Create( IDB_IL_TAB, 16, 1, RGB( 0,255,0 ));
m_wndWorkspace.SetTabImageList( &m_TabImages );
m_wndWorkspace.EnableDocking( CBRS_ALIGN_ANY );
DockControlBar( &m_wndWorkspace, AFX_IDW_DOCKBAR_LEFT);
// set the popoup menu id.
m_wndWorkspace.SetMenuID( IDR_MAINFRAME, NULL, 1 );
}
/*
// create the memory docking window.
{
if( !m_wndMemory.Create(this, ID_VIEW_MEMORY,
_T("Memory"), CSize(150, 150), CBRS_BOTTOM ))
{
TRACE0("Failed to create dialog bar m_wndMemory\n");
return -1; // fail to create
}
m_wndMemory.EnableDocking( CBRS_ALIGN_ANY );
DockControlBar( &m_wndMemory, AFX_IDW_DOCKBAR_BOTTOM);
// set the popoup menu id.
m_wndMemory.SetMenuID( IDR_MAINFRAME, NULL, 1 );
}
*/
// create the output docking window.
{
if( !m_wndOutput.Create(this, ID_VIEW_OUTPUT,
_T("Output"), CSize(150, 150), CBRS_BOTTOM ))
{
TRACE0("Failed to create dialog bar m_wndOutput\n");
return -1; // fail to create
}
m_wndOutput.EnableDocking( CBRS_ALIGN_ANY );
DockControlBar( &m_wndOutput, AFX_IDW_DOCKBAR_BOTTOM);
// set the popoup menu id.
m_wndOutput.SetMenuID( IDR_MAINFRAME, NULL, 1 );
}
// Hide the memory control bar.
//ShowControlBar( &m_wndMemory, FALSE, FALSE );
//ShowWindow(SW_SHOWMAXIMIZED);
// Restore the previous bar and window states.
LoadBarState(_T("Bar State"));
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style&=~FWS_ADDTOTITLE;
if( !CCJMDIFrameWnd::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
{
CCJMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CCJMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
BOOL CMainFrame::ShowWindowEx(int nShowCmd)
{
//CView * active = GetActiveView();//获取当前视类指针
m_state.LoadWindowPos(this);
ShowWindow(nShowCmd);
LoadBarState(_T("Bar State"));
return TRUE;
}
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
m_state.SaveWindowPos(this);
SaveBarState(_T("Bar State"));
CCJMDIFrameWnd::OnClose();
}
void CMainFrame::OnShowAllcollum()
{
// TODO: Add your command handler code here
CMDIChildWnd *pChild = (CMDIChildWnd *) GetActiveFrame();
CView *pView =pChild-> GetActiveView();
if(pView != NULL){
m_bShowall=!m_bShowall;
pView->PostMessage(WM_COLLUM_MESSAGE,(WPARAM)(&m_bShowall),0);//发送消息
}
}
void CMainFrame::OnUpdateShowAllcollum(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if(pCmdUI->m_nID==ID_SHOW_ALLCOLLUM)
{
pCmdUI->SetCheck(m_bShowall);
}
}
LRESULT CMainFrame::OnListInfo(WPARAM wParam, LPARAM lParam)
{
CString strmsg=(CString)(LPCTSTR)wParam;
m_wndOutput.AddStringtoList(strmsg);
return 0;
}
void CMainFrame::OnClearMessage()
{
// TODO: Add your command handler code here
m_wndOutput.ClearListInfo();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -