当前位置:网站首页>MFC writes a suggested text editor
MFC writes a suggested text editor
2022-06-26 07:50:00 【Don't hit me, it hurts!】
1. Use ANSI Character set
2. open , preservation , Of the exit button ID Not for IDopen,IDsave,IDcancel
3. Create a variable for the text edit box m_Edit, Category is Value, The variable type is CString.
-------------------- Open the handler of the button
void CeditDlg::OnBnClickedopen()
{
// TODO: Add control notification handler code here
int i=0;
char s[10000];
char szFilter[]=" text file (*.txt)|*.txt|All File(*,*)|*,*||";
CFileDialog OpenDlg(true,"*.txt",0,0,szFilter);
int x=OpenDlg.DoModal();
if(x==IDOK)
{
CFile fileOpen;
try{
fileOpen.Open(OpenDlg.GetPathName(),CFile::modeRead);
i=fileOpen.GetLength();
fileOpen.Read(s,i);
fileOpen.Close();
}catch(CFileException *e){
CString str;
str.Format(" The reason why reading data failed is :%d",e->m_cause);
MessageBox(str);
fileOpen.Abort();
e->Delete();
}
}
CString str(s,i);
m_Edit1=str;
UpdateData(false);
}
--------------------------------------- Save button handler
void CeditDlg::OnBnClickedsave()
{
// TODO: Add control notification handler code here
UpdateData();
char szFilter[]=" text file (*.txt)|*.txt|All File(*,*)|*,*||";
CFileDialog SaveDlg(false,"*.txt",0,0,szFilter);
int x=SaveDlg.DoModal();
if(x==IDOK)
{
CFile fileSave;
try{
fileSave.Open(SaveDlg.GetPathName(),CFile::modeCreate|CFile::modeWrite);
fileSave.Write(m_Edit1,m_Edit1.GetLength());
fileSave.Close();
}catch(CFileException *e){
CString str;
str.Format(" The reason why saving data failed is :%d",e->m_cause);
MessageBox(str);
fileSave.Abort();
e->Delete();
}
}
}
---------------------------------------------- The exit button uses the default function
void CeditDlg::OnBnClickedCancel()
{
// TODO: Add control notification handler code here
CDialogEx::OnCancel();
}
边栏推荐
- 花指令wp
- Informatics Olympiad 1355: string matching problem (STRs)
- [recommend 10 easy idea plug-ins with less tedious and repetitive code]
- Xiaosha's counting (bit operation, Combinatorial Mathematics) - Niuke
- Use middleware to record slow laravel requests
- Redis(5)----浅谈压缩列表
- [UVM practice] Chapter 3: UVM Fundamentals (3) field automation mechanism
- Deeply analyze storage costs and find cost reduction solutions
- Redis (4) -- Talking about integer set
- The long path of Xiao Sha (graph theory, Euler diagram)
猜你喜欢

解决 psycopg2.NotSupportedError: PQconninfo not available in libpq < 9.3

Sanic based services use celery to complete dynamic modification timing tasks

My colleague asked a question I never thought about. Why did kubernetes' superfluous' launch the static pod concept?

Apache InLong毕业成为顶级项目,具备百万亿级数据流处理能力!

Oracle creates stored procedures with return values and executes SQL calls
![Jemter stress test - visualization tool support - [installation]](/img/e9/9acda4e37c98cc21df9499684205c6.png)
Jemter stress test - visualization tool support - [installation]

Exploration and practice of incremental data Lake in station B

What are the characteristics of digital factory in construction industry

Niuniu looks at the cloud (greedy, hash, push formula) - the first session of Niuke winter vacation training camp

Take you three minutes to get started typescript
随机推荐
Okhttp3 source code explanation (IV) cache strategy, disadvantages of Android mixed development
Go language custom DNS resolver practice yyds dry inventory
Open a file at line with'filename:line'syntax - open a file at line with'filename:line' syntax
Summary of domestic database examination data (continuously updated)
[UVM basics] connect of UVM_ Phase execution sequence
Hand drawn style chart library chart Implementation principle of xkcd
Redis (4) -- Talking about integer set
PCB miscellaneous mail
Esp32-c3 introductory tutorial WiFi part ⑥ - WIFI intelligent distribution network based on serial port
Jemter stress test - Basic request - [teaching]
Uniapp scrolling load (one page, multiple lists)
[UVM foundation] UVM_ Driver member variable req definition
My colleague asked a question I never thought about. Why did kubernetes' superfluous' launch the static pod concept?
Machine learning - Iris Flower classification
4 best practices for wireless (OTA) updates
What is the difference between bone conduction earphones and ordinary earphones? Advantages of bone conduction earphones
Multi interface switching in one UI of QT
The first multi platform webcast of 2021ccf award ceremony pays tribute to the winners! CCF outstanding engineer
I want to create SQL data (storage structure)
Jmeter压力测试-Web代理本地接口测试【教学篇】