本文整理汇总了C++中COleDataObject::IsDataAvailable方法的典型用法代码示例。如果您正苦于以下问题:C++ COleDataObject::IsDataAvailable方法的具体用法?C++ COleDataObject::IsDataAvailable怎么用?C++ COleDataObject::IsDataAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COleDataObject
的用法示例。
在下文中一共展示了COleDataObject::IsDataAvailable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnEditPaste
void CHexEdit::OnEditPaste()
{
COleDataObject obj;
if (obj.AttachClipboard())
{
HGLOBAL hmem = NULL;
if (obj.IsDataAvailable(RegisterClipboardFormat("BinaryData")))
{
hmem = obj.GetGlobalData(RegisterClipboardFormat("BinaryData"));
}
else if (obj.IsDataAvailable(CF_TEXT))
{
hmem = obj.GetGlobalData(CF_TEXT);
}
if(hmem)
{
LPBYTE p = (BYTE*)::GlobalLock(hmem);
DWORD dwSizeMem=::GlobalSize(hmem);
DWORD dwSizeSel=GetSelLength();
DWORD dwLen =dwSizeMem>dwSizeSel?dwSizeSel:dwSizeMem;
int insert;
NormalizeSel();
if(m_selStart == 0xffffffff)
{
if(m_currentMode == EDIT_LOW)
m_currentAddress++;
insert = m_currentAddress;
SelInsert(m_currentAddress, dwLen);
}
else
{
insert = m_selStart;
SelDelete(m_selStart,m_selStart+dwLen-1);
SelInsert(insert, dwLen);
}
memcpy(m_pData+insert, p, dwLen);
m_currentAddress = insert+dwLen;
// RepositionCaret(m_currentAddress);
ResetPos();
Invalidate(FALSE);
::GlobalUnlock(hmem);
}
}
}
示例2: OnEditPaste
void CHexEdit::OnEditPaste()
{
COleDataObject obj;
if (obj.AttachClipboard())
{
HGLOBAL hmem = NULL;
if (obj.IsDataAvailable(RegisterClipboardFormat(L"BinaryData")))
{
hmem = obj.GetGlobalData(RegisterClipboardFormat(L"BinaryData"));
}
else if (obj.IsDataAvailable(CF_TEXT))
{
hmem = obj.GetGlobalData(CF_TEXT);
}
if(hmem)
{
LPBYTE p = (BYTE*)::GlobalLock(hmem);
DWORD dwLen = ::GlobalSize(hmem);
int insert;
int oa = m_currentAddress;
NormalizeSel();
if(m_selStart == 0xffffffff)
{
if(m_currentMode == EDIT_LOW)
m_currentAddress++;
insert = m_currentAddress;
SelInsert(m_currentAddress, dwLen);
}
else
{
insert = m_selStart;
SelDelete(m_selStart, m_selEnd);
SelInsert(insert, dwLen);
SetSel(-1, -1);
}
memcpy(m_pData+insert, p, dwLen);
m_currentAddress = oa;
RedrawWindow();
::GlobalUnlock(hmem);
}
}
}
示例3: OnContextMenu
void CHexEdit::OnContextMenu(CWnd*, CPoint point)
{
// by latelee
#if 0
// CG: This block was added by the Pop-up Menu component
{
if (point.x == -1 && point.y == -1)
{
//keystroke invocation
CRect rect;
GetClientRect(rect);
ClientToScreen(rect);
point = rect.TopLeft();
point.Offset(5, 5);
}
CMenu menu;
VERIFY(menu.LoadMenu(CG_IDR_POPUP_HEX_EDIT));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pPopup->EnableMenuItem(ID_EDIT_UNDO, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
if(!IsSelected())
{
pPopup->EnableMenuItem(ID_EDIT_CLEAR, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
pPopup->EnableMenuItem(ID_EDIT_CUT, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
pPopup->EnableMenuItem(ID_EDIT_COPY, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
}
{
COleDataObject obj;
if (obj.AttachClipboard())
{
if(!obj.IsDataAvailable(CF_TEXT) && !obj.IsDataAvailable(RegisterClipboardFormat("BinaryData")))
pPopup->EnableMenuItem(ID_EDIT_PASTE, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
}
}
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
this);
}
#endif
}
示例4: GetAcceptableClipFormat
CLIPFORMAT CRulerRichEdit::GetAcceptableClipFormat(LPDATAOBJECT lpDataOb, CLIPFORMAT format)
{
if (m_bPasteSimple)
#ifndef _UNICODE
return CF_TEXT;
#else
return CF_UNICODETEXT;
#endif
static CLIPFORMAT cfRtf = (CLIPFORMAT)::RegisterClipboardFormat(CF_RTF);
static CLIPFORMAT cfRtfObj = (CLIPFORMAT)::RegisterClipboardFormat(CF_RETEXTOBJ);
CLIPFORMAT formats[] =
{
COutlookHelper::CF_OUTLOOK,
CF_HDROP,
cfRtf,
cfRtfObj,
CF_BITMAP,
#ifndef _UNICODE
CF_TEXT,
#else
CF_UNICODETEXT,
#endif
CF_METAFILEPICT,
CF_SYLK,
CF_DIF,
CF_TIFF,
CF_OEMTEXT,
CF_DIB,
CF_PALETTE,
CF_PENDATA,
CF_RIFF,
CF_WAVE,
CF_ENHMETAFILE
};
const long nNumFmts = sizeof(formats) / sizeof(CLIPFORMAT);
COleDataObject dataobj;
dataobj.Attach(lpDataOb, FALSE);
for (int nFmt = 0; nFmt < nNumFmts; nFmt++)
{
if (format && format == formats[nFmt])
return format;
if (dataobj.IsDataAvailable(formats[nFmt]))
return formats[nFmt];
}
// all else
return CF_HDROP;
}
示例5:
void CEx27bView::OnUpdateEditPaste(CCmdUI* pCmdUI)
{
// Make sure that object data is available
COleDataObject dataObject;
if (dataObject.AttachClipboard() &&
dataObject.IsDataAvailable(m_cfEmbedded)) {
pCmdUI->Enable(TRUE);
} else {
pCmdUI->Enable(FALSE);
}
}
示例6: Paste
void kGUISystemWin::Paste(kGUIString *s)
{
COleDataObject obj;
if (obj.AttachClipboard())
{
#if 0
if (obj.IsDataAvailable(CF_UNICODETEXT))
{
HGLOBAL hmem = obj.GetGlobalData(CF_UNICODETEXT);
CMemFile sf((BYTE*) ::GlobalLock(hmem),(UINT) ::GlobalSize(hmem));
CString buffer;
LPSTR str = buffer.GetBufferSetLength((int)::GlobalSize(hmem));
sf.Read(str,(UINT) ::GlobalSize(hmem));
::GlobalUnlock(hmem);
s->SetEncoding(ENCODING_UTF8);
s->SetString(buffer);
}
else if (obj.IsDataAvailable(CF_TEXT))
#else
if (obj.IsDataAvailable(CF_TEXT))
#endif
{
HGLOBAL hmem = obj.GetGlobalData(CF_TEXT);
CMemFile sf((BYTE*) ::GlobalLock(hmem),(UINT) ::GlobalSize(hmem));
CString buffer;
LPSTR str = buffer.GetBufferSetLength((int)::GlobalSize(hmem));
sf.Read(str,(UINT) ::GlobalSize(hmem));
::GlobalUnlock(hmem);
// s->SetEncoding(ENCODING_UTF8);
s->SetEncoding(ENCODING_8BIT);
s->SetString(buffer);
}
}
}
示例7:
// without this, idiot will paste files and other objects into window
HRESULT
mfc_edit_view::QueryAcceptData(LPDATAOBJECT lpdataobj,
CLIPFORMAT* lpcfFormat, DWORD reco,
BOOL fReally, HGLOBAL hMetaPict)
{
if (*lpcfFormat == CF_TEXT) return S_OK;
COleDataObject dataobj;
dataobj.Attach(lpdataobj, FALSE);
if (*lpcfFormat==0 && dataobj.IsDataAvailable(CF_TEXT)) {
*lpcfFormat = CF_TEXT;
return S_OK;
}
return S_FALSE;
}
示例8: OnContextMenu
void CEditEx::OnContextMenu(CWnd* pWnd, CPoint point)
{
if (point.x == -1 && point.y == -1)
{
//keystroke invocation
CRect rect;
GetClientRect(rect);
ClientToScreen(rect);
point = rect.TopLeft();
point.Offset(5, 5);
}
CMenu menu;
VERIFY(menu.LoadMenu(RIGHTBUTTON));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
//pPopup->EnableMenuItem(ID_EDIT_UNDO, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
//pPopup->EnableMenuItem(ID_EDIT_CLEAR, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
//pPopup->EnableMenuItem(ID_EDIT_CUT, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
//pPopup->EnableMenuItem(ID_EDIT_COPY, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
COleDataObject obj;
if (obj.AttachClipboard())
{
if(!obj.IsDataAvailable(CF_TEXT) && !obj.IsDataAvailable(RegisterClipboardFormat(L"BinaryData")))
pPopup->EnableMenuItem(ID_EDIT_PASTE, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
}
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
this);
return;
}
示例9: OkToPaste
///////////////////////////////////////////////////
// Verify that data you can handle is on the clipboard.
///////////////////////////////////////////////////
BOOL CDragDropMgr::OkToPaste()
{
COleDataObject obj;
BOOL bOk = FALSE;
if (!obj.AttachClipboard())
return FALSE;
for (int i=0;i < m_nFormats.GetSize() && !bOk;i++)
{
UINT nF = m_nFormats.GetAt(i);
bOk = obj.IsDataAvailable(m_nFormats.GetAt(i));
}
return bOk;
}
示例10: tools_getClipboardText
bool zstringEx::tools_getClipboardText()
{
COleDataObject obj;
if (obj.AttachClipboard())
{
if (obj.IsDataAvailable(CF_TEXT))
{
HGLOBAL hmem = obj.GetGlobalData(CF_TEXT);
CMemFile sf((BYTE*) ::GlobalLock(hmem), (UINT)::GlobalSize(hmem));
mem_data.mem_resizenull((UINT)::GlobalSize(hmem));
sf.Read(mem_data.mem_string, (UINT)::GlobalSize(hmem));
::GlobalUnlock(hmem);
sf.Close();
return true;
}
}
return false;
}
示例11: DragEnter
STDMETHODIMP CSite::DragEnter(IDataObject * pDataObject, WORD grfKeyState, POINTL pt,DWORD * pdwEffect)
{
if(!pDataObject||!pdwEffect)
return E_INVALIDARG;
COleDataObject pData;
pData.Attach(pDataObject,FALSE);
FORMATETC stFormatTEXT = {CF_TEXT,NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL};
if(pData.IsDataAvailable(CF_HDROP))
{
*pdwEffect = DROPEFFECT_NONE;
return E_INVALIDARG;
}
*pdwEffect = DROPEFFECT_COPY;
return S_OK;
}
示例12: OnEditPaste
void CUIDesignerView::OnEditPaste()
{
COleDataObject dataObject;
dataObject.AttachClipboard();
if(dataObject.IsDataAvailable(m_cfUI))
{
CFile* pFile = dataObject.GetFileData(m_cfUI);
if (pFile == NULL)
return;
int len = (int)pFile->GetLength();
char* pstrXML = new char[len];
pFile->Read(pstrXML, len);
PasteUI(StringConvertor::Utf8ToWide(pstrXML));
delete[] pstrXML;
delete pFile;
}
}
示例13: GetDocument
BOOL CEx27bView::MakeMetafilePict(COleDataSource* pSource)
{
CEx27bDoc* pDoc = GetDocument();
COleDataObject dataObject;
LPDATAOBJECT pDataObj; // OLE object's IDataObject interface
VERIFY(pDoc->m_lpOleObj->QueryInterface(IID_IDataObject,
(void**) &pDataObj) == S_OK);
dataObject.Attach(pDataObj);
FORMATETC fmtem;
SETFORMATETC(fmtem, CF_METAFILEPICT, DVASPECT_CONTENT, NULL,
TYMED_MFPICT, -1);
if (!dataObject.IsDataAvailable(CF_METAFILEPICT, &fmtem)) {
TRACE("CF_METAFILEPICT format is unavailable\n");
return FALSE;
}
// Just copy the metafile handle from the OLE object
// to the clipboard data object
STGMEDIUM stgmm;
VERIFY(dataObject.GetData(CF_METAFILEPICT, &stgmm, &fmtem));
pSource->CacheData(CF_METAFILEPICT, &stgmm, &fmtem);
return TRUE;
}
示例14: GetAcceptableClipFormat
CLIPFORMAT CUrlRichEditCtrl::GetAcceptableClipFormat(LPDATAOBJECT lpDataOb, CLIPFORMAT format)
{
CLIPFORMAT formats[] =
{
CF_HDROP,
#ifndef _UNICODE
CF_TEXT,
#else
CF_UNICODETEXT,
#endif
};
const long nNumFmts = sizeof(formats) / sizeof(CLIPFORMAT);
// check for outlook first
if (COutlookHelper::IsOutlookObject(lpDataOb))
return COutlookHelper::CF_OUTLOOK;
// else
COleDataObject dataobj;
dataobj.Attach(lpDataOb, FALSE);
for (int nFmt = 0; nFmt < nNumFmts; nFmt++)
{
if (format && format == formats[nFmt])
return format;
if (dataobj.IsDataAvailable(formats[nFmt]))
return formats[nFmt];
}
#ifndef _UNICODE
return CF_TEXT;
#else
return CF_UNICODETEXT;
#endif
}
示例15: DoDrop
////////////////////////////////////////////////////////
//This function loads data from the clipboard
//or drag/drop into a local object of the proper
//type for use.
//
//If pasting from clipboard, pDataObject should be NULL.
//
//You usually call this function from:
//
//1) Your view class's OnDrop() method when a drag-
// drop operation ends, to load the data for use.
//
//2) Your view (or document) class's OnEditPaste()
// method when doing a paste from the clipboard.
////////////////////////////////////////////////////////
BOOL CDragDropMgr::DoDrop(
CObject* pO,
COleDataObject* pDataObject,
LPCTSTR lpstrFormat)
{
// try
{
UINT format = ::RegisterClipboardFormat(lpstrFormat);
COleDataObject* pObj = NULL;
// If from clipboard, then there is no
// data object passed in, so use a local copy
if (pDataObject == NULL)
pObj = new COleDataObject();
else
pObj = pDataObject;
// Make sure basic data is OK
if (pObj == NULL)
return FALSE;
else if (pDataObject == NULL &&
!pObj->AttachClipboard())
return FALSE;
else if (format == 0 || pO == NULL)
return FALSE;
else if (!pObj->IsDataAvailable(format))
return FALSE;
FORMATETC fe;
fe.cfFormat = format;
fe.tymed = TYMED_HGLOBAL;
fe.lindex = -1;
fe.dwAspect = DVASPECT_CONTENT;
fe.ptd = NULL;
// Fetch the data from the OLE data object
HGLOBAL hMem = pObj->GetGlobalData(format,&fe);
if (hMem == NULL)
return FALSE;
// TRY
{
CMemFile mf((BYTE*)::GlobalLock(hMem), ::GlobalSize(hMem));
CArchive ar(&mf, CArchive::load);
pO->Serialize(ar);
ar.Close();
::GlobalUnlock(hMem);
pObj->Release();
if (pDataObject == NULL)
delete pObj;
return TRUE;
}
/* CATCH_ALL(ce)
{
pObj->Release();
if (pDataObject == NULL)
delete pObj;
return FALSE;
}
END_CATCH_ALL*/
}
/* catch(...)
{
CErrorDlg error;
error.Error("Drag/drop error", "A serious error occured while dropping objects. Please report this to the Construct team.");
return FALSE;
}*/
//.........这里部分代码省略.........