📄 creatordlg.cpp
字号:
// CREATORDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CREATOR.h"
#include "CREATORDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCREATORDlg dialog
CCREATORDlg::CCREATORDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCREATORDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCREATORDlg)
m_out = _T("");
m_rout = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CCREATORDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCREATORDlg)
DDX_Text(pDX, IDC_OUT, m_out);
DDX_Text(pDX, IDC_ROUT, m_rout);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCREATORDlg, CDialog)
//{{AFX_MSG_MAP(CCREATORDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CREATOR, OnCreator)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCREATORDlg message handlers
BOOL CCREATORDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CCREATORDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CCREATORDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
//*****************************主程序******************************88
HCURSOR CCREATORDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CCREATORDlg::OnCreator()
{//原语还没处理!!!
// TODO: Add your control notification handler code here
int iBuffer=0;
CFile myFile;
CString sTemp;
CLine myCLine;
KEY mykey;
DIGIT digit;
pc=0;
//记录是第几个标号
Tablecount=1;
m_out.Empty();
//**********************************程序开始******************************************
UpdateData();
//m_rout="e:\\4.txt";
m_rout="e:\\test.txt";
if(myFile.Open(m_rout,CFile::modeRead)==FALSE)
{MessageBox("错误的路径!");
//return;
}
else
{
headread(myFile);//读头文件
FirstReadText(myFile);
SecondRead(sText);
//MessageBox("文件已打开");
}
sTemp.Format("%d",pc);
m_out=codestring+"/r/n一共"+sTemp +"字节";
// m_out=sText;
// m_out=index.Getstring();
myFile.Close();
UpdateData(FALSE);
}
//*****************************主要流程函数***************************************
BOOL CCREATORDlg::headread(CFile &myFile)
{CLine tempCLine;
CString temp;
while(1)
{tempCLine.InputLine(readline(myFile));
if(tempCLine.GetiCount()==1 && IsStart(tempCLine.DrawWord(1)))
return FALSE;
//增加处理代码
ADDINDEX(tempCLine);
}
return TRUE;
}
void CCREATORDlg::FirstReadText(CFile &myFile)
{
CLine myLine;
CString mystring,temp;
KEY mykey;
int i=0;//i循环变量,sByte记录程序字节数的和,即pc的值
do
{myLine.InputLine(readline(myFile));
if(myLine.GetiCount()==1&&!mykey.IsKeyword(myLine.DrawWord(1))) //是标号
{
mystring.Format("%x",pc);
sTable+=myLine.DrawWord(1)+':'+mystring+"\r\n"; //处理标号
sText+=myLine.GetAllString();
continue;
}//申明,标号不能为最后一行,否则陷入死循环
else if(myLine.IsTheEnd())
{
sText+=myLine.GetAllString(); break;}
else{
if (myLine.DrawWord(1)=="PRIM")
{
sText+=myLine.GetAllString();
pc+=myLine.GetiCount();
continue;
}
pc+=mykey.GetBYTELength(myLine);
sText+=SubStringindex(myLine);}
//用一个字符串sText记录正文内容
//INDEX 代换
}
while(!myLine.IsTheEnd());
sText+="\r\n";
}
void CCREATORDlg::SecondRead(CString sText)
{CLine myLine;
KEY key;
CString word;
CString line;
;
int nword=0;
do
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -