当前位置:网站首页>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();
}
边栏推荐
- Cloud native integration data warehouse heavy release
- Flower instruction WP
- JS event loop mechanism
- The long path of Xiao Sha (graph theory, Euler diagram)
- [North Asia data recovery] a server data recovery method in which the partitions in the RAID5 array are formatted due to the misoperation of the NTFS file system
- How MySQL implements the RC transaction isolation level
- Is it safe for individuals to buy stocks with compass software? How to buy stocks
- Flutter (III) - master the usage of dart language in an article
- The first multi platform webcast of 2021ccf award ceremony pays tribute to the winners! CCF outstanding engineer
- Class class of box selection four to and polygon box selection based on leaflet encapsulation
猜你喜欢

Data governance: from top project to data culture!

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

Median segmentation (find rules) - Niuke

ReW_p

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

buuresevewp

Google Earth engine (GEE) 02 basic knowledge and learning resources
![[recommend 10 easy idea plug-ins with less tedious and repetitive code]](/img/74/69ca02e3d83404f7b0df07c308a59d.png)
[recommend 10 easy idea plug-ins with less tedious and repetitive code]
![[recommend an entity class conversion tool mapstruct, which is powerful and easy to use]](/img/7b/43becce42192fb5e0469465aa27a36.png)
[recommend an entity class conversion tool mapstruct, which is powerful and easy to use]

Here is the command to display the disk space usage. Go ahead and pay attention to more wonderful things!
随机推荐
Two models of OSPF planning: double tower Raider and dog tooth crisscross
Teach you how to use the harmonyos local simulator
buuresevewp
Hand drawn style chart library chart Implementation principle of xkcd
Opencv mouse event + interface interaction drawing rectangle polygon selection ROI
Redis (4) -- Talking about integer set
Solve psycopg2 NotSupportedError: PQconninfo not available in libpq < 9.3
Chapter VI (pointer)
Chapter 4 (functions and preprocessing)
数据中心灾难恢复的重要参考指标:RTO和RPO
Google Earth engine (GEE) 02 basic knowledge and learning resources
Chapter 5 (array)
OSPF design principles, commands take H3C as an example
Informatics Orsay all in one 1354: bracket matching test
Multisensor fusion sensing
Here is the command to display the disk space usage. Go ahead and pay attention to more wonderful things!
Opencv鼠标事件+界面交互之绘制矩形多边形选取感兴趣区域ROI
C#/. Net phase VI 01C Foundation_ 02:vs2019 basic operations, excluding code files, smart tips, data types, differences between float and double, and differences between string and string
[UVM basics] TLM common data receiving and sending and data receiving examples
Xiaosha's counting (bit operation, Combinatorial Mathematics) - Niuke