Reyes
May 26th, 1999, 04:59 AM
Hello!!!
I have a problem to copy in the Clipboard.
I need to copy the contents from a CEdit and a CListBox (both in the same View) in the Clipboard. I have try but I can't make this.
Somebody can help me?
Thanks, Reyes
Gaetan Frenoy
May 26th, 1999, 05:33 AM
You should first try to read the article of Keith Rule about clipboard manipulations.
You'll find it at :
http://www.codeguru.com/clipboard/copypaste_dragdrop.shtml
Regards,
--
Gaetan Frenoy (aka Gaff)
Reyes
May 31st, 1999, 04:59 AM
Hello Gaetan
First, thanks for your answer, and I'm sorry, I have been able to write to you before. I have tried to make a "Copy" using the article of Keith Rule that you sayied to me, but when I have tried "Paste" in NOTEPAD the datas, I have recived an error mesagge.
In fact, I don't want to use OLE elements. I have made copy and past in other views directly form the CEdit and CCombobox controls. But in this case I can use the same technique because I want to store the datas from two controls.
I have tried with several ways. I think that the better is:
void CAnfragView::OnEditCopy()
{
CString sText, sLine;
int iResult;
m_edStatement.GetWindowText(sText);
sText += TEXT("\r\n");
iResult = m_lbResult.GetCount();
for (int i = 0; i < iResult; i++) {
m_lbResult.GetText(i,sLine);
sText += sLine + TEXT("\r\n");
}
if ( !OpenClipboard() )
{
AfxMessageBox( "Cannot open the Clipboard" );
return;
}
// Remove the current Clipboard contents
if( EmptyClipboard() )
{
AfxMessageBox( "Cannot empty the Clipboard" );
return;
}
// ...
// Get the currently selected data
// ...
// For the appropriate data formats...
if ( ::SetClipboardData( CF_UNICODETEXT, sText ) == NULL )
{
AfxMessageBox( "Unable to set Clipboard data" );
CloseClipboard();
return;
}
// ...
CloseClipboard();
}
But I have problems with this too. It doesn't make empty the clipboard and it doesn't store the datas in the clipboard.
Can you say to me What I make wrong?
Thanks,
Reyes