Solved

CRichEditView drop file

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

18 Experts available now in Live!

Get 1:1 Help Now