Nathan R.
2003-10-19 10:04:23 UTC
Hello,
I use COleDataSource to set the Clipboard for my application. I am
using CFSTR_FILEDESCRIPTOR and CFSTR_FILECONTENTS with ColeDataSource
and IStream. My application displays the objects of a remote system
which resembles the directory structure of windows. Please can anybody
tell how to use an IStream object (implemented by me) ca be used for
getting data. Here is the code i used...
BOOL CMyDataSource::OnRenderData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM
lpStgMedium)
{
BOOL bReturn = FALSE;
if (lpFormatEtc->cfFormat == g_cfFileContents)
{
HRESULT hr = S_FALSE;
//Create an instance of CIStreamImpl which implements IStream
CIStreamImpl *pStreamImpl= new CIStreamImpl();
hr = pStreamImpl->QueryInterface(IID_IStream,(void FAR*
FAR*)&pStreamImpl);
if(SUCCEEDED(hr))
{
lpStgMedium->tymed = TYMED_ISTREAM;
lpStgMedium->pstm = pStreamImpl;
lpStgMedium->pUnkForRelease = NULL;
bReturn = TRUE;//Set the return value
}else
pStreamImpl->Release();
}
else
if (lpFormatEtc->cfFormat == g_cfFileGroupDescriptor)
{
lpStgMedium->tymed = TYMED_HGLOBAL;
lpStgMedium->hGlobal = CreateFileGroupDescriptor();
bReturn = TRUE; //Set the return value
}
return bReturn;
}
In CreateFileGroupDescriptor(), the file group descriptor is created
with file descriptor flag (dwFlag) FD_FILESIZE. nFileSizeLow = 1024
and nFileSizeHigh = 0; When the user clicks on "paste" menu item in
the explorer, the CIStreamImpl::Read( void *pv, ULONG cb, ULONG
*pcbRead ) is getting called. But the value of the parameter ''cb" is
always 16384 :-(. Also it seems that the Read(...) method being called
just as in an infinite loop. Why the Windows Explorer does not call
Read method with cb=1024 (Which is set in Filegroupdescriptor)? Can
anybody help me to figure out the things?
Here is the read method of CIStremImpl, cb is always 16384.
STDMETHODIMP CIStreamImpl::Read( void *pv, ULONG cb, ULONG *pcbRead )
{
if(NULL == pv) return STG_E_INVALIDPOINTER;
if(cb > 0)
{
TRACE ("The value of cb=%d\n",cb);
//Set some data
memset( pv, 'A', cb);
*pcbRead = cb;
return S_OK;
}
return S_FALSE;
}
regards
Nathan
I use COleDataSource to set the Clipboard for my application. I am
using CFSTR_FILEDESCRIPTOR and CFSTR_FILECONTENTS with ColeDataSource
and IStream. My application displays the objects of a remote system
which resembles the directory structure of windows. Please can anybody
tell how to use an IStream object (implemented by me) ca be used for
getting data. Here is the code i used...
BOOL CMyDataSource::OnRenderData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM
lpStgMedium)
{
BOOL bReturn = FALSE;
if (lpFormatEtc->cfFormat == g_cfFileContents)
{
HRESULT hr = S_FALSE;
//Create an instance of CIStreamImpl which implements IStream
CIStreamImpl *pStreamImpl= new CIStreamImpl();
hr = pStreamImpl->QueryInterface(IID_IStream,(void FAR*
FAR*)&pStreamImpl);
if(SUCCEEDED(hr))
{
lpStgMedium->tymed = TYMED_ISTREAM;
lpStgMedium->pstm = pStreamImpl;
lpStgMedium->pUnkForRelease = NULL;
bReturn = TRUE;//Set the return value
}else
pStreamImpl->Release();
}
else
if (lpFormatEtc->cfFormat == g_cfFileGroupDescriptor)
{
lpStgMedium->tymed = TYMED_HGLOBAL;
lpStgMedium->hGlobal = CreateFileGroupDescriptor();
bReturn = TRUE; //Set the return value
}
return bReturn;
}
In CreateFileGroupDescriptor(), the file group descriptor is created
with file descriptor flag (dwFlag) FD_FILESIZE. nFileSizeLow = 1024
and nFileSizeHigh = 0; When the user clicks on "paste" menu item in
the explorer, the CIStreamImpl::Read( void *pv, ULONG cb, ULONG
*pcbRead ) is getting called. But the value of the parameter ''cb" is
always 16384 :-(. Also it seems that the Read(...) method being called
just as in an infinite loop. Why the Windows Explorer does not call
Read method with cb=1024 (Which is set in Filegroupdescriptor)? Can
anybody help me to figure out the things?
Here is the read method of CIStremImpl, cb is always 16384.
STDMETHODIMP CIStreamImpl::Read( void *pv, ULONG cb, ULONG *pcbRead )
{
if(NULL == pv) return STG_E_INVALIDPOINTER;
if(cb > 0)
{
TRACE ("The value of cb=%d\n",cb);
//Set some data
memset( pv, 'A', cb);
*pcbRead = cb;
return S_OK;
}
return S_FALSE;
}
regards
Nathan