Solved

QueryAcceptData Problem

Posted on 2006-11-13
3
537 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 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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