Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

QueryAcceptData Problem

Posted on 2006-11-13
3
Medium Priority
?
549 Views
Last Modified: 2013-11-20
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


0
Comment
Question by:wdhough
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 2000 total points
ID: 17930689
because there is no declaration for _oleData and hMetaPict...

probably you need hMetaFile instead of hMetaPict and you need to register clipboard formats  cfRichTextFormat & cfRichTextAndObjects .......

so try this :

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);

UINT cfRichTextFormat = ::RegisterClipboardFormat(_T("Rich Text Format"));       //**NOTE
UINT cfRichTextAndObjects = ::RegisterClipboardFormat(_T("RichEdit Text and Objects")); //**NOTE
 
     // if format is 0, then force particular formats if available
     if (*lpcfFormat == 0 && (m_nPasteType == 0))
     {
          if (dataobj.IsDataAvailable(CLIPFORMAT)cfRichTextAndObjects) //**NOTE
               return S_OK;
          else if (dataobj.IsDataAvailable((CLIPFORMAT)cfRichTextFormat) //**NOTE
          {
               *lpcfFormat = (CLIPFORMAT)cfRichTextFormat; //**NOTE
               return S_OK;
          }
          else if (dataobj.IsDataAvailable(CF_TEXT))
          {
               *lpcfFormat = CF_TEXT;
               return S_OK;
          }
     }
     // paste OLE formats
     DoPaste(dataobj, *lpcfFormat, hMetaFile); //**NOTE
     return S_FALSE;
}

Have a look at commented as **NOTE statements above.

-MAHESH
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 17933991
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
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17936184
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
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question