CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    12

    Copy in the Clipboard

    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


  2. #2
    Join Date
    May 1999
    Posts
    4

    Re: Copy in the Clipboard

    You should first try to read the article of Keith Rule about clipboard manipulations.
    You'll find it at :
    http://www.codeguru.com/clipboard/co...dragdrop.shtml

    Regards,

    --
    Gaetan Frenoy (aka Gaff)

  3. #3
    Join Date
    May 1999
    Posts
    12

    Re: Copy in the Clipboard

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured