本文整理汇总了C++中LPDATAOBJECT::SetData方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDATAOBJECT::SetData方法的具体用法?C++ LPDATAOBJECT::SetData怎么用?C++ LPDATAOBJECT::SetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDATAOBJECT
的用法示例。
在下文中一共展示了LPDATAOBJECT::SetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeToDataObject
int writeToDataObject(LPDATAOBJECT lpDataObject, UINT fid, std::istream& is, HWND hwnd, int bufsize)
{
HANDLE hDib = 0;
// The client placed the bitmap HANDLE in the stream
// Note: the SController adds a trailing null char to the data (hence the +1)
if ((bufsize) && (bufsize == sizeof (HANDLE) + 1))
{
HANDLE hBitmapTemp;
is.read ((char *)&hBitmapTemp, sizeof (HANDLE));
hDib = hBitmapTemp;
//hDib = (HBITMAP)::OleDuplicateData (hBitmapTemp, Format::F_IGLAYER, 0);
}
if (hDib == 0)
{
return 0;
}
FORMATETC format;
STGMEDIUM medium;
ZeroMemory (&format, sizeof (format));
ZeroMemory (&medium, sizeof (medium));
format.cfFormat = static_cast<CLIPFORMAT> (fid);
format.dwAspect = DVASPECT_CONTENT;
format.ptd = 0;
format.lindex = -1;
medium.tymed = format.tymed = TYMED_HGLOBAL;
medium.hGlobal = hDib;
medium.pUnkForRelease = 0;
lpDataObject->SetData (&format, &medium, TRUE);
return 1;
}
示例2: _AfxLoadObjectFromStreamedPropset
BOOL AFXAPI _AfxLoadObjectFromStreamedPropset(LPUNKNOWN lpUnknown, LPSTREAM lpStream)
{
ASSERT_POINTER(lpUnknown, IUnknown);
ASSERT_POINTER(lpStream, IStream);
BOOL bSuccess = FALSE;
LPDATAOBJECT pDataObj = NULL;
if (SUCCEEDED(lpUnknown->QueryInterface(IID_IDataObject,
(LPVOID*)&pDataObj)))
{
ASSERT_POINTER(pDataObj, IDataObject);
// Set the persistent propset format on the object.
FORMATETC formatEtc;
STGMEDIUM stgMedium;
formatEtc.cfFormat = _AfxGetClipboardFormatPersistPropset();
formatEtc.ptd = NULL;
formatEtc.dwAspect = DVASPECT_CONTENT;
formatEtc.lindex = -1;
formatEtc.tymed = TYMED_ISTREAM;
stgMedium.tymed = TYMED_ISTREAM;
stgMedium.pstm = lpStream;
stgMedium.pUnkForRelease = NULL;
bSuccess = SUCCEEDED(pDataObj->SetData(&formatEtc, &stgMedium, FALSE));
pDataObj->Release();
}
return bSuccess;
}