CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Clipboard

  1. #1
    Join Date
    Mar 1999
    Posts
    2

    Clipboard



    Hi,

    I am trying to implement OnEditCopy() for my application to copy a user defined data structure to clipboard with a user

    defined registered clipboard format. The implementation is present in a DLL. Everything goes fine except the

    SetClipBoard call with fails with exception code CLIPBRD_E_CANT_SET. The sequence of operation is as follows..

    char *pData = GetUserDefinedData();

    long len = GetDataLength();

    memset((void *) &stg, 0, sizeof(STGMEDIUM));

    stg.tymed = TYMED_HGLOBAL;

    stg.hGlobal = GlobalAlloc(GMEM_SHARE, len);

    memcpy((char *)stg.hGlobal, pData, len);

    // put the stuff on the clipboard

    COleDataSource *pSrc = new COleDataSource;

    pSrc->CacheData(currentClipFormat, &stg);

    pSrc->SetClipboard(); //This call fails


    Can anybody help?????


    Thanks




  2. #2
    Join Date
    Mar 1999
    Posts
    9

    Re: Clipboard



    You might try the following:

    char *pData = GetUserDefinedData();

    long len = GetDataLength();

    memset((void *) &stg, 0, sizeof(STGMEDIUM));

    stg.tymed = TYMED_HGLOBAL;

    stg.hGlobal = ::GlobalAlloc(GMEM_SHARE, len+1);

    char *gData = (char*)::GlobalLock(stg.hGlobal);

    ASSERT(gData);

    strcpy(gData, pData);

    ::GlobalUnlock(stg.hGlobal);

    // put the stuff on the clipboard

    COleDataSource *pSrc = new COleDataSource;

    pSrc->CacheGlobalData(currentClipFormat, stg.hGlobal);

    pSrc->SetClipboard();



    // .................


    Good luck.


    Allen



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