Solved

CRichEditView drop file

Posted on 1998-06-07
2
256 Views
Last Modified: 2013-11-19
How can I make my Rich  Edit view accept dropped files like Notepad does? i.e.; immediately render it it plain text instead of creating an OLE object.
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 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1316138
You'll need to do a couple of things:

1. Derive a new class from CRichEditView.

2. Override QueryAcceptData to return TRUE if the object supports the format CF_TEXT:


HRESULT CDrvLayView::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: 1316139
Silly me. You had answered this question for me before, but my app would only accept text dragged from other apps, not files. Gee, could this have anything to do with the fact that I had never called DragAcceptFiles()? :)
    You've answered my question but would you be so kind as to let me know if there is an easy way to insert the dropped file's text in the open view (at the dropped point without erasing what's currently there) this is an MDI app and the dropped files only work when they are dropped on the frame, not in a view.
    I would ask another question but I only have 25 points left. I would understand if you do not wish to answer this second question. If you do, I will ask a non-question and give you all of my current points when you respond.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to determine file rename from EventLog ? 2 58
notReplace  challenge 53 151
wordmultiple challenge 12 156
Path of Workbook 3 87
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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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