-
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
-
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