void CjiantiebanDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
//复制
CString str;
GetDlgItem(IDC_EDIT1)->GetWindowText(str);
HGLOBAL hClip;
if (OpenClipboard())
{
EmptyClipboard();
hClip=GlobalAlloc(GMEM_MOVEABLE,str.GetLength()+1);
char *buff;
buff=(char*)GlobalLock(hClip);
// _tcscpy_s(buff,str.GetLength()+1,str);
memcpy(buff,str,str.GetLength()+1);
GlobalUnlock(hClip);
SetClipboardData(CF_TEXT,hClip);
CloseClipboard();
AfxMessageBox(_T("已将数据存入剪贴板"));
}
}
void CjiantiebanDlg::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
//粘贴
CString str;
HANDLE hClip;
if (OpenClipboard())
{
hClip=GetClipboardData(CF_TEXT);
char *buff;
buff=(char*)GlobalLock(hClip);
str=buff;
GlobalUnlock(hClip);
CloseClipboard();
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
}
}
字符集需要设置为多字符集