Solved

RichText Overkill

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ORA-01403: no data found 43 116
lucky13 challenge 11 168
Annoying "thing" blocks my view 4 146
I could not set window to top 4 63
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: 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.

752 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