📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "RMM.h"
#include "sen.h"
#include "RMMAPI.h"
#include "word.h"
#include "MainFrm.h"
#include "UserDlg.h"
#include <string.h>
#include <map>
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
CString strInp;
FILE* fpInp;
CString result;
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_DO, OnDo)
ON_BN_CLICKED(IDC_OPEN, OnOpen)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_BN_CLICKED(IDC_MAKE, OnMake)
ON_COMMAND(ID_COUNT, OnCount)
//}}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
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
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
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
//m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
//EnableDocking(CBRS_ALIGN_ANY);
//DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
CCreateContext* pContext)
{
BOOL rtn=m_wndSplitter.CreateStatic(this,2,1);
m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(Csen), CSize(0, 0), pContext);
m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(Cword), CSize(0, 0), pContext);
m_wndSplitter.SetRowInfo(0,200,0);
m_DialogBar.Create(this,IDD_DIALOGBAR,CBRS_TOP,IDD_DIALOGBAR);
return rtn;
}
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::OnFileOpen()
{
CString strOut;
Csen* psen=(Csen*)m_wndSplitter.GetPane(0,0);
Cword* pword=(Cword*)m_wndSplitter.GetPane(1,0);
CFileDialog FileDialog(true);
if ( FileDialog.DoModal() == IDOK ){
strInp=FileDialog.GetPathName( );
FILE* fpInp;
fpInp=fopen(strInp.GetBuffer(1024),"rb");
if ( fpInp == NULL ){
AfxMessageBox("Error open file!\n");
}
char szLine[1024];
while( fgets(szLine,1024,fpInp) != NULL ){
strOut+=szLine;
}
fclose(fpInp);
psen->SetWindowText(strOut);
}
RMMInit("segment.idx","segment.dat");
}
void CMainFrame::OnDo() {
CString TszSeged;
char szSegmented[1024];
Csen* psen=(Csen*)m_wndSplitter.GetPane(0,0);
Cword* pword=(Cword*)m_wndSplitter.GetPane(1,0);
int len=psen->GetWindowTextLength();
CString szSeged;
int nPos1=1;
psen->GetWindowText(szSeged.GetBuffer(len+1),len+1);
fpInp=fopen(strInp.GetBuffer(1024),"rb");
if ( fpInp == NULL ){
AfxMessageBox("Error open file!\n");
}
char szLine[1024];
while(!feof(fpInp)){
fscanf(fpInp,"%s",szLine);
RMMMain(szLine,szSegmented);
result+=szSegmented;
result+=" ";
}
fclose(fpInp);
pword->SetWindowText(result);
}
void CMainFrame::OnOpen()
{
// TODO: Add your control notification handler code here
CString strOut;
Csen* psen=(Csen*)m_wndSplitter.GetPane(0,0);
CFileDialog FileDialog(true);
if ( FileDialog.DoModal() == IDOK ){
strInp=FileDialog.GetPathName( );
fpInp=fopen(strInp.GetBuffer(1024),"rb");
if ( fpInp == NULL ){
AfxMessageBox("Error open file!\n");
}
char szLine[1024];
while( fgets(szLine,1024,fpInp) != NULL ){
strOut+=szLine;
}
fclose(fpInp);
psen->SetWindowText(strOut);
}
RMMInit("segment.idx","segment.dat");
}
void CMainFrame::OnSave()
{
// TODO: Add your control notification handler code here
char szDir[1024];
::GetCurrentDirectory(1024,szDir);
CFileDialog FileDialog(false);
if(FileDialog.DoModal()==IDOK)
{
CString strPath=FileDialog.GetPathName();
FILE *fpOut;
fpOut=fopen(strPath.GetBuffer(1024),"wb");
if ( fpOut == NULL ){
AfxMessageBox("Error open file!\n");
return;
}
Csen* psen=(Csen*)m_wndSplitter.GetPane(0,0);
int len=psen->GetWindowTextLength();
CString szSeged;
psen->GetWindowText(szSeged.GetBuffer(len+1),len+1);
fprintf(fpOut,"%s\n",szSeged.GetBuffer(len+1));
fclose(fpOut);
}
}
void CMainFrame::OnMake()
{
// TODO: Add your control notification handler code here
CString TszSeged;
char szSegmented[1024];
Csen* psen=(Csen*)m_wndSplitter.GetPane(0,0);
Cword* pword=(Cword*)m_wndSplitter.GetPane(1,0);
int len=psen->GetWindowTextLength();
CString szSeged;
int nPos1=1;
psen->GetWindowText(szSeged.GetBuffer(len+1),len+1);
fpInp=fopen(strInp.GetBuffer(1024),"rb");
if ( fpInp == NULL ){
AfxMessageBox("Error open file!\n");
}
char szLine[1024];
while(!feof(fpInp)){
fscanf(fpInp,"%s",szLine);
RMMMain(szLine,szSegmented);
result+=szSegmented;
result+=" ";
}
fclose(fpInp);
pword->SetWindowText(result);
}
void CMainFrame::OnCount()
{
// TODO: Add your command handler code here
CUserDlg obUserDlg;
if ( obUserDlg.DoModal() == IDOK ){}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -