MFC实现简单文本编辑器
以下为MFC实现简单文本编辑器的完整源码。
首先,需要创建一个新的MFC应用程序工程。在创建对话框时,需要添加一个编辑框控件并设置为多行文本框。
在工程中添加以下代码:
MyTextEditorDlg.h:
#pragma once
class CMyTextEditorDlg : public CDialogEx
{
public:
CMyTextEditorDlg(CWnd* pParent = nullptr);
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_MYTEXTEDITOR_DIALOG };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnFileSave();
afx_msg void OnFileOpen();
afx_msg void OnEditCopy();
afx_msg void OnEditCut();
afx_msg void OnEditPaste();
afx_m