Link to home
Start Free TrialLog in
Avatar of wdhough
wdhough

asked on

QueryAcceptData Problem

Hi,

I am trying to override QueryAcceptData in my CRichEditview derived class.

HRESULT MyView::QueryAcceptData(LPDATAOBJECT 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(*lpcfFormat))
            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.cfRichTextAndObjects)) // native avail, let richedit do as it wants
                  return S_OK;
            else if (dataobj.IsDataAvailable((CLIPFORMAT)_oleData.cfRichTextFormat))
            {
                  *lpcfFormat = (CLIPFORMAT)_oleData.cfRichTextFormat;
                  return S_OK;
            }
            else if (dataobj.IsDataAvailable(CF_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


ASKER CERTIFIED SOLUTION
Avatar of mahesh1402
mahesh1402
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DanRollins
I confirmed what mahesh1402 pointed out:  You are getting those errors because you made some typographical errors when you copied the original MFC source code.  Replace...
    hMetaFile
...with...
    hMetaPict
...and replace...
     _oleData
...with...
   dataobj
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