📄 proper.cpp
字号:
// proper.cpp : implementation file
//
#include "stdafx.h"
#include "MFCpl0.h"
#include "proper.h"
#include "propshxiugai.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Cproper property page
IMPLEMENT_DYNCREATE(Cproper, CPropertyPage)
Cproper::Cproper() : CPropertyPage(Cproper::IDD)
{
//{{AFX_DATA_INIT(Cproper)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
Cproper::~Cproper()
{
}
void Cproper::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cproper)
DDX_Control(pDX, IDC_LIST1, m_list1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Cproper, CPropertyPage)
//{{AFX_MSG_MAP(Cproper)
ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
ON_BN_CLICKED(IDC_BUTTONsave, OnBUTTONsave)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cproper message handlers
void Cproper::getadd(CString name)
{
filename=name;
}
BOOL Cproper::OnSetActive()
{
CStdioFile file;
CString temp;
CString temp2="";
CListBox* listbox;
listbox=(CListBox*)(GetDlgItem(IDC_LIST1));
listbox->ResetContent();
file.Open(filename,CFile::modeRead);
GetDlgItem(IDC_EDIT1)->SetWindowText(filename);
int i=0;
while(file.ReadString(temp))
{
i++;
if(i<10)
{
temp2.Format("%3d%s",i," ");
}
else if((i>=10)&&(i<100))
{
temp2.Format("%3d%s",i," ");
}
else if((i>=100)&&(i<1000))
{
temp2.Format("%3d%s",i," ");
}
temp=temp2+temp;
listbox->AddString(temp);
}
file.Close();
//MessageBox(temp);
return CPropertyPage::OnSetActive();
}
void Cproper::OnDblclkList1()
{
CString temp;
int line=m_list1.GetCurSel();
m_list1.GetText(m_list1.GetCurSel(),temp);
Cpropshxiugai shxiugai("修改");
shxiugai.xiugai(temp);
shxiugai.SetWizardMode();
if(shxiugai.DoModal()==ID_WIZFINISH )
{
CString xiugai=shxiugai.proper1.m_edit1;
// MessageBox(xiugai);
m_list1.DeleteString(line);
m_list1.InsertString(line,xiugai);
}
else
{
MessageBox("取消操作!");
}
// MessageBox(temp);
}
void Cproper::OnBUTTONsave()
{
int line;
CString temp,temp1,temp2,savename;
line=m_list1.GetCount();
// temp.Format("%d",line);
// MessageBox(temp);
GetDlgItem(IDC_EDIT1)->GetWindowText(savename);
CStdioFile file;
file.Open(savename,CFile::modeCreate);
file.Close();
file.Open(savename,CFile::modeWrite);
for(int i=0;i<line;i++)
{
m_list1.GetText(i,temp1);
temp2=temp1.Mid(6,temp1.GetLength()-6);
file.WriteString(temp2);
file.WriteString("\n");
}
file.Close();
}
void Cproper::OnButton1()
{
// TODO: Add your control notification handler code here
int line=m_list1.GetCurSel();
m_list1.InsertString(line,"");
m_list1.SetSel(line,true);
}
void Cproper::OnButton2()
{
// TODO: Add your control notification handler code here
int line=m_list1.GetCurSel();
m_list1.DeleteString (line);
m_list1.SetSel(line+1,true);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -