一、新建工程:
二、编辑资源:
1、编辑对话框
2、编辑“编辑控件”
3、编辑“按钮控件”
按钮ID 按钮标题
IDC_COPY_BUTTON Copy
IDC_CUT_BUTTON1 Cut
IDC_CLEAR_BUTTON2 Clear
IDC_UNDO_BUTTON1 Undo
三、添加变量、函数
1、添加变量
2、添加函数
四、为新建函数添加代码:
1、进入新建函数所在文件
2、为新建函数添加代码(红色部分) void CCEdit_3Dlg::OnCopyButton() void CCEdit_3Dlg::OnCutButton1() void CCEdit_3Dlg::OnClearButton2() void CCEdit_3Dlg::OnUndoButton1() void CCEdit_3Dlg::OnCancel() 五、编译 六、运行 七、函数说明 1、CEdit::SetSel函数声明 void SetSel(int nStarChar,int nEndChar,BOOL bNoscroll=FALSE) nStarChar:选中字符起始位置 nEndCha: 选中字符终止位置 功能: 选择编辑框中的字符。nStarChar为“0”,nEndCha为“-1”,则选中编辑框内的全部内容 2、CEdit::Copy函数声明 void Copy() 功能:将编辑框内的内容复制到剪贴板 3、CEdit::Paste函数声明 void Paste() 功能:将剪贴板中的内容复制到编辑框中的指定位置 4、CEdit::Cut函数声明 void Cut() 功能:将编辑框内的内容剪切到剪贴板 5、CEdit:: Undo函数声明 void Undo() 功能:将撤销上一次对编辑框控件的操作。
{
// TODO: Add your control notification handler code here
m_edit1.SetSel(0,-1);
m_edit1.Copy();
m_edit2.SetSel(0,-1);
m_edit2.ReplaceSel("");
m_edit2.Paste();
}
{
// TODO: Add your control notification handler code here
m_edit1.SetSel(0,-1);
m_edit1.Copy();
m_edit1.ReplaceSel("");
m_edit2.SetSel(0,-1);
m_edit2.ReplaceSel("");
m_edit2.Paste();
}
{
// TODO: Add your control notification handler code here
m_edit1.SetSel(0,-1);
m_edit1.ReplaceSel("");
m_edit2.SetSel(0,-1);
m_edit2.ReplaceSel("");
}
{
// TODO: Add your control notification handler code here
m_edit1.Undo();
m_edit2.Undo();
}
{
// TODO: Add extra cleanup here
OnOK();
//CDialog::OnCancel();
}