📄 dialog1.cpp
字号:
// Dialog1.cpp : implementation file
//
#include "stdafx.h"
#include "caoyuting.h"
extern CCaoyutingApp theApp;
#include "Dialog1.h"
#include "Dialog2.h"
#include "Dialog3.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CCaoyutingApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDialog1 dialog
CDialog1::CDialog1(CWnd* pParent /*=NULL*/)
: CDialog(CDialog1::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialog1)
m_str = _T("");
m_name = _T("");
//}}AFX_DATA_INIT
}
void CDialog1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialog1)
DDX_Control(pDX, IDC_LIST1, m_cOut);
DDX_LBString(pDX, IDC_LIST1, m_str);
DDX_Text(pDX, IDC_EDIT1, m_name);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialog1, CDialog)
//{{AFX_MSG_MAP(CDialog1)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialog1 message handlers
void CDialog1::OnButton1()
{
// TODO: Add your control notification handler code here
bool i=false;
CString str;
UpdateData(true);
for(int j=0;j<theApp.n;j++)
if (m_name==theApp.nam[j])
{
i=true;
theApp.str1=theApp.str[j];
}
if(i==true)
{
CDialog3 dialog3;
dialog3.DoModal();
}
else
{
CString str1,str2;
if(m_name=="Program"||m_name=="procedure"||m_name=="begin"||m_name=="end"||m_name=="if"||m_name=="then"||m_name=="else"||m_name=="while"||m_name=="do"||m_name=="integer"||m_name=="call"||m_name=="begin"||m_name=="real")
{
str1="关键字";
str2="0";
}
else if(m_name=="+"||m_name=="-"||m_name=="*"||m_name=="/"||m_name=="~"||m_name=="&"||m_name=="|"||m_name=="<"||m_name=="<="||m_name==">"||m_name==">="||m_name=="="||m_name=="<>"||m_name==":"||m_name==":="||m_name==","||m_name=="."||m_name==";"||m_name=="/*"||m_name=="*/"||m_name=="("||m_name==")")
{
str1="运算符";
str2="0";
}
else
{
str2=" ";
str1="标识符";
}
str.Format("%s %s %s",str1,str2,m_name);
m_cOut.AddString(str);
}
}
void CDialog1::OnButton3()
{
// TODO: Add your control notification handler code here
CDialog1::OnOK();
}
BOOL CDialog1::OnInitDialog()
{
CDialog::OnInitDialog();
CString str1;
str1.Format("type val name ");
m_cOut.AddString(str1);
for(int i=0;i<theApp.n;i++)
m_cOut.AddString(theApp.str[i]);
m_str=str1+theApp.str[i];
UpdateData(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialog1::OnButton2()
{
// TODO: Add your control notification handler code here
int nIndex=m_cOut.GetCurSel();
if(nIndex!=LB_ERR)
m_cOut.DeleteString(nIndex);
// delete(CString *)m_cOut.GetItemDataPtr(nIndex);
//UpdateData(FALSE);
}
//DEL void CDialog1::OnButton4()
//DEL {
//DEL m_cOut.AddString("q");
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -