wdhough
asked on
QueryAcceptData Problem
Hi,
I am trying to override QueryAcceptData in my CRichEditview derived class.
HRESULT MyView::QueryAcceptData(LP DATAOBJECT lpdataobj,CLIPFORMAT *lpcfFormat,DWORD dwReco,BOOL bReally,HGLOBAL hMetaFile)
{
ASSERT(lpcfFormat != NULL);
if (!bReally) // not actually pasting
return S_OK;
// if direct pasting a particular native format allow it
if (IsRichEditFormat(*lpcfFor mat))
return S_OK;
COleDataObject dataobj;
dataobj.Attach(lpdataobj, FALSE);
// if format is 0, then force particular formats if available
if (*lpcfFormat == 0 && (m_nPasteType == 0))
{
if (dataobj.IsDataAvailable(( CLIPFORMAT )_oleData. cfRichText AndObjects )) // native avail, let richedit do as it wants
return S_OK;
else if (dataobj.IsDataAvailable(( CLIPFORMAT )_oleData. cfRichText Format))
{
*lpcfFormat = (CLIPFORMAT)_oleData.cfRic hTextForma t;
return S_OK;
}
else if (dataobj.IsDataAvailable(C F_TEXT))
{
*lpcfFormat = CF_TEXT;
return S_OK;
}
}
// paste OLE formats
DoPaste(dataobj, *lpcfFormat, hMetaPict);
return S_FALSE;
}
as you can see thus far i am just copying the code from the CRichEditView implementation. But I receive the following errors which i dont understand
error C2065: '_oleData' : undeclared identifier
error C2065: 'hMetaPict' : undeclared identifier
I have other errors after this but i think they relate to this, any ideas please. FYI i am doing this because I dont want DoPaste to be called under certain circumstances DoPaste is not virtual so i didnt think i could override it, if this isnt the case then please suggest your ideas for this, thanks
Will
I am trying to override QueryAcceptData in my CRichEditview derived class.
HRESULT MyView::QueryAcceptData(LP
{
ASSERT(lpcfFormat != NULL);
if (!bReally) // not actually pasting
return S_OK;
// if direct pasting a particular native format allow it
if (IsRichEditFormat(*lpcfFor
return S_OK;
COleDataObject dataobj;
dataobj.Attach(lpdataobj, FALSE);
// if format is 0, then force particular formats if available
if (*lpcfFormat == 0 && (m_nPasteType == 0))
{
if (dataobj.IsDataAvailable((
return S_OK;
else if (dataobj.IsDataAvailable((
{
*lpcfFormat = (CLIPFORMAT)_oleData.cfRic
return S_OK;
}
else if (dataobj.IsDataAvailable(C
{
*lpcfFormat = CF_TEXT;
return S_OK;
}
}
// paste OLE formats
DoPaste(dataobj, *lpcfFormat, hMetaPict);
return S_FALSE;
}
as you can see thus far i am just copying the code from the CRichEditView implementation. But I receive the following errors which i dont understand
error C2065: '_oleData' : undeclared identifier
error C2065: 'hMetaPict' : undeclared identifier
I have other errors after this but i think they relate to this, any ideas please. FYI i am doing this because I dont want DoPaste to be called under certain circumstances DoPaste is not virtual so i didnt think i could override it, if this isnt the case then please suggest your ideas for this, thanks
Will
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No ! I dont think you need to replace _oleData with dataobj...
What you are doing is correct to attach lpdataobj to dataobj....
COleDataObject dataobj;
dataobj.Attach(lpdataobj, FALSE);
you need to define cfRichTextAndObjects and cfRichTextFormat for rich text formats as shown above...as there are no class member as such for 'COleDataObject' type class.
-MAHESH
What you are doing is correct to attach lpdataobj to dataobj....
COleDataObject dataobj;
dataobj.Attach(lpdataobj, FALSE);
you need to define cfRichTextAndObjects and cfRichTextFormat for rich text formats as shown above...as there are no class member as such for 'COleDataObject' type class.
-MAHESH
hMetaFile
...with...
hMetaPict
...and replace...
_oleData
...with...
dataobj