Solved

RichText Overkill

Posted on 1998-03-21
3
174 Views
Last Modified: 2013-11-19
I'm using a CRichEditView based MDI for large file support and custom colors/fonts, but I don't want users to be able to drag and drop anything but plain text into the client area, is there a simple way of disabling this without learning OLE?
0
Comment
Question by:midthune
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
Comment Utility
Yes, you will need to derive a class from CRichEditView and override QueryAcceptData(). If the clipboard format is CF_TEXT, call the base class's implementation otherwise return S_FALSE.

0
 
LVL 15

Expert Comment

by:Tommy Hui
Comment Utility
Your code would look like

HRESULT CMyView::QueryAcceptData(LPDATAOBJECT lpdataobj, CLIPFORMAT* lpcfFormat,
      DWORD dwReco, BOOL bReally, HGLOBAL hMetaPict)
{
      if (lpcfFormat == NULL)
            return S_FALSE;

      if (!bReally)
            return S_OK;

      COleDataObject obj;
      obj.Attach(lpdataobj);
      if (obj.IsDataAvailable(CF_TEXT))
      {
            *lpcfFormat = CF_TEXT;
            obj.Detach();
            return S_OK;
      }
      else
      {
            obj.Detach();
      }

      TRACE("format = %d\r\n", *lpcfFormat);

      if (*lpcfFormat == CF_TEXT)
            return CRichEditView::QueryAcceptData(lpdataobj, lpcfFormat, dwReco,
                  bReally, hMetaPict);
      else
            return S_FALSE;
}

0
 

Author Comment

by:midthune
Comment Utility
Aha! Well, I was on the right track... I just didn't know what function to override (this OLE stuff is confusing for mere mortals like myself). Thank you!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now