Solved

RichText Overkill

Posted on 1998-03-21
3
178 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
ID: 1317123
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
ID: 1317124
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
ID: 1317125
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 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