Solved

QueryAcceptData Problem

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

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

Suggested Solutions

Title # Comments Views Activity
Expand data scrubbing tool 13 36
Line meaning 9 97
Problem to App source 6 120
Example code 13 42
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

734 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