Solved

RichText Overkill

Posted on 1998-03-21
3
175 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

22 Experts available now in Live!

Get 1:1 Help Now