Solved

QueryAcceptData Problem

Posted on 2006-11-13
3
543 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 500 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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

626 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