⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.cpp

📁 与vc++界面十分类似的词法分析器
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "CFF.h"
#include "NewDlg.h"
#include "MainFrm.h"
//#include "CFFView.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()
	ON_COMMAND(ID_WORKBAR, OnWorkbar)
	ON_UPDATE_COMMAND_UI(ID_WORKBAR, OnUpdateWorkbar)
	ON_COMMAND(ID_DUGBAR, OnDugbar)
	ON_UPDATE_COMMAND_UI(ID_DUGBAR, OnUpdateDugbar)
	ON_COMMAND(ID_VIDEOBAR, OnVideobar)
	ON_UPDATE_COMMAND_UI(ID_VIDEOBAR, OnUpdateVideobar)
	ON_COMMAND(IDM_LISTVIEW, OnListView)
	ON_COMMAND(IDM_VIEWWORD, OnViewWord)
	ON_COMMAND(ID_OPEN, OnOpen)
	ON_COMMAND(ID_PLAY, OnPlay)
	ON_COMMAND(ID_CLOSE, OnClose)
	ON_COMMAND(ID_NEW_FILE, OnNewFile)
	//}}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
	m_pChildFrame=NULL;
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWnd::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 toolbar\n");
		return -1;      // fail to create
	}
	if (!m_wndWorkBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndWorkBar.LoadToolBar(IDR_WORKBAR))
	{
		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_wndMyBar.Create(_T("工作区"), this, CSize(150, 150),
        TRUE, 123))//AFX_IDW_CONTROLBAR_FIRST + 33))
    {
       TRACE0("Failed to create mybar\n");
       return -1;      // fail to create
	}

	if (!m_wndEditBar.Create(_T("输出"), this, CSize(100, 100),
        TRUE, 123))//AFX_IDW_CONTROLBAR_FIRST + 33))
    {
       TRACE0("Failed to create editbar\n");
       return -1;      // fail to create
	}

	if (!m_wndVideoBar.Create(_T("娱乐区"), this, CSize(200, 150),
        TRUE, 123))//AFX_IDW_CONTROLBAR_FIRST + 33))
    {
       TRACE0("Failed to create videobar\n");
       return -1;      // fail to create
	}

	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle()|
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	m_wndWorkBar.SetBarStyle(m_wndWorkBar.GetBarStyle()|
		CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

    m_wndMyBar.SetBarStyle(m_wndMyBar.GetBarStyle() |WS_DLGFRAME|
        CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	m_wndEditBar.SetBarStyle(m_wndEditBar.GetBarStyle() |WS_DLGFRAME |
        CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	m_wndVideoBar.SetBarStyle(m_wndVideoBar.GetBarStyle() |WS_DLGFRAME |
        CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    m_wndMyBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndEditBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndWorkBar.EnableDocking(CBRS_ALIGN_ANY);
	m_wndVideoBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);
    DockControlBar(&m_wndWorkBar);
	/*CRect rc_tool,rc_work;
	m_wndToolBar.GetWindowRect(&rc_tool);
	m_wndWorkBar.GetWindowRect(&rc_work);
	rc_tool.BottomRight()=rc_tool.TopLeft()+rc_work.Size();
	DockControlBar(&m_wndWorkBar,AFX_IDW_DOCKBAR_TOP,&rc_tool);
    RecalcLayout();*/
    DockControlBar(&m_wndMyBar, AFX_IDW_DOCKBAR_LEFT);
	DockControlBar(&m_wndEditBar, AFX_IDW_DOCKBAR_BOTTOM);
	DockControlBar(&m_wndVideoBar,AFX_IDW_DOCKBAR_RIGHT);

	m_wndMyBar.LoadState(_T("BarState1"));
	LoadBarState(_T("BarState1"));

	ShowControlBar(&m_wndVideoBar,false,false);
	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CMDIFrameWnd::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
{
	CMDIFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CMDIFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers


void CMainFrame::OnWorkbar() 
{
	// TODO: Add your command handler code here
    BOOL bShow = m_wndMyBar.IsVisible();
	ShowControlBar(&m_wndMyBar, !bShow, FALSE);
}

void CMainFrame::OnUpdateWorkbar(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable();
	pCmdUI->SetCheck(m_wndMyBar.IsVisible());
}

void CMainFrame::OnDugbar() 
{
	// TODO: Add your command handler code here
	BOOL bShow = m_wndEditBar.IsVisible();
	ShowControlBar(&m_wndEditBar, !bShow, FALSE);
}

void CMainFrame::OnUpdateDugbar(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable();
	pCmdUI->SetCheck(m_wndEditBar.IsVisible());
}

void CMainFrame::OnVideobar() 
{
	// TODO: Add your command handler code here
	BOOL bShow = m_wndVideoBar.IsVisible();
	ShowControlBar(&m_wndVideoBar, !bShow, FALSE);
}

void CMainFrame::OnUpdateVideobar(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->Enable();
	pCmdUI->SetCheck(m_wndVideoBar.IsVisible());
}

void CMainFrame::OnListView() 
{
	// TODO: Add your command handler code here
	CFileFind find;
	if(find.FindFile(theApp.m_TempFile))
		theApp.AddFile(theApp.m_TempFile);
}

void CMainFrame::OnViewWord() 
{
	// TODO: Add your command handler code here
	CString str;str.LoadString(IDR_TXT);
	theApp.AddFile(str);
}

void CMainFrame::OnOpen()
{
		if(m_wndVideoBar.OnOpen())
			ShowControlBar(&m_wndVideoBar,true,false);
}

void CMainFrame::OnPlay()
{
	m_wndVideoBar.OnPlay();
}

void CMainFrame::OnClose()
{
	m_wndVideoBar.OnClose();
}

void CMainFrame::OnNewFile() 
{
	// TODO: Add your command handler code here
	CNewDlg dlg;
	if(dlg.DoModal()==IDOK)
		theApp.AddFile(dlg.filename);
}


void CMainFrame::CloseWorkRgn()
{
	m_wndMyBar.CloseWorkRgn();

}

void CMainFrame::ShowWorkRgn()
{
	m_wndMyBar.ShowWorkRgn();

}


CEditBar* CMainFrame::GetEditBar()
{
	return &m_wndEditBar;
}

CMyBar* CMainFrame::GetMyBar()
{
	return &m_wndMyBar;
}

CVideoBar* CMainFrame::GetVideoBar()
{
	return &m_wndVideoBar;
}

void CMainFrame::OpenVideo(CString fname, CString ext)
{
	m_wndVideoBar.Open(fname,ext);
	ShowControlBar(&m_wndVideoBar,true,false);

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -