void CClipDlg::OnButton1() { // TODO: Add your control notification handler code here if(OpenClipboard()) { CString mystr; HGLOBAL hClip; char *pstr; // OpenClipboard(); EmptyClipboard(); GetDlgItemText(IDC_EDIT1,mystr); hClip = GlobalAlloc(GMEM_MOVEABLE,mystr.GetLength()+1); pstr =(char *) GlobalLock(hClip); strcpy(pstr,mystr); GlobalUnlock(hClip); SetClipboardData(CF_TEXT,hClip); CloseClipboard(); }} void CClipDlg::OnButton2() { // TODO: Add your control notification handler code here if(OpenClipboard()) { if(IsClipboardFormatAvailable(CF_TEXT)) { HGLOBAL hclip; char *pstr; hclip=GetClipboardData(CF_TEXT); pstr = (char *)GlobalLock(hclip); GlobalUnlock(hclip); SetDlgItemText(IDC_EDIT3,pstr); CloseClipboard(); } }}

评论