|
-
March 29th, 1999, 05:27 PM
#1
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
-
March 29th, 1999, 07:44 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|