Solved

CRichEditView drop file

Posted on 1998-06-07
2
253 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
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

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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 film showing how OnPage and Connectwise integration works.

932 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

17 Experts available now in Live!

Get 1:1 Help Now